title

fire chief's random developer tidbits
Showing posts with label soap. Show all posts
Showing posts with label soap. Show all posts

Wednesday, July 31, 2013

Jaxb name conflict with underscores

<xs:element name="_SortFields" nillable="true" type="tns:_SortFields"/>

will conflict with

<xs:element name="SortFields" nillable="true" type="tns:SortFields"/>

giving the error:

Two declarations cause a collision in the ObjectFactory class.
  line 300 of file:blah.xsd

(Related to above error) This is the other declaration.   
  line 385 of file:blah.xsd

because it is removing underscores from names by default.

A bindings file like this will fix it:
<jxb:bindings version="2.1" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
              xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
              xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" 
              xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
              xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jxb:globalBindings underscoreBinding="asCharInWord">
        <xjc:simple/>
        <xjc:serializable />
    </jxb:globalBindings>
</jxb:bindings>