I am rather new to Java having much more experience in mainframes and .NET . However, I am now moving much of our code to Java . I must reference a number of web services that follow a similar pattern. I do not have the luxury of changing the design of these services. They are not under my control. When importing the WSDL for one of these services I receive many instances of the same problem.
The messages basically say that two lines in the XSD file have caused JAXB to created classes with the same name. In each case the messages
occur in pairs.
Here is a little background. In some cases, the service offers two elements with similar names. E.g. "emp_id_0415", an Integer and
"_emp_id_0415", a String . The difference is in the underscore. The web service offers two columns for each numeric element because the
service retrieves data from a source that canât be trusted to return good numeric values. In this case, if a valid integer can't be had from
the data source, the service will set "emp_id_0415" to NULL and "_emp_id_0415" will contain an explanation of the conversion error. The web service doesn't throw an exception because it's up to my program to make the decision if the bad data is critical or not, or if it can be repaired.
With that said, here is an example of two lines that are causing the issue:
<xs:element name="emp_id_0415" type="xs:decimal" default="0" minOccurs="0" msdata:Ordinal="2" />
<xs:element name="_emp_id_0415" type="xs:string" default="" minOccurs="0" msdata:Ordinal="3" />
It would appear that JAXB (I think this is the package that creates Java classes from XSD files) is creating the same class name for both elements. It appears to be ignoring the underscore character when it creates a class name.
After a few hours of research, I think it might be possible to get around this by setting underscoreBinding property in globalBindings to
âasCharInWordâ. This article seems to discuss how to do this but it is short on details:
Furthermore, I am at a total loss on how to approach this in NetBeans. In addition, I have had no luck finding a good sample or tutorial. I come to you in a desperate quest for advice. Am I even on the right track? Can anyone help?