Search code examples
javajaxbwsimport

Collision in ObjectFactory of two things that should be only one


i am trying to do a wsimport (through netbeans 6.9.1) in a WSDL from a 3rd party, but it keeps generating this error in JAXB:

Two declarations cause a collision in the ObjectFactory class.

The collision is about this two things:

In messages.xsd:

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

In service.xsd:

<xs:element name="Ping">
  <xs:complexType>
    <xs:sequence>
      <xs:element xmlns:q1="http://www.3rd-party-uri-here/messages/" minOccurs="0" name="request" nillable="true" type="q1:PingRequest" /> <!-- HERE! -->
    </xs:sequence>
  </xs:complexType>
</xs:element>

I saw here in stackoverflow that JAXB cannot handle cases were two distinct elements have the same name or names differing only by capitalization. However, in this case the two elements should really be the samething (the second is referencing the first). So, what can I do?


Solution

  • I had a similar problem, described here: wsimport - two declarations cause collision, same line number given

    I was getting this error when running this command:

    wsimport ./bwWsdl.xml -p com.generated -Xnocompile -d ../src -extension -keep -XadditionalHeaders -B-XautoNameResolution
    

    Thanks to the help of @Petru Gardea I was able to eventually get past this by omitting the -p com.generated package specification to wsimport. So this is what I was eventually able to run to get past this problem:

    wsimport ./bwWsdl.xml -Xnocompile -d ../src -extension -keep -XadditionalHeaders -B-XautoNameResolution