wsimport - Two declarations cause a collision, same line given

Cuga picture Cuga · Aug 9, 2012 · Viewed 30k times · Source

Trying to use wsimport to generate a client for a SOAP endpoint. The WSDL and all XSD files used are local copies.

This is the command being executed:

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

Which gives this error:

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 16 of file:/schemas/newSchema.xsd

[ERROR] (Related to above error) This is the other declaration.   
  line 16 of file:/schemas/newSchema.xsd

Note the line number is the same for the reported collision.

Here's the schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
  version="2.004" id="OTA2003A2009A">

  <xs:complexType name="TPA_ExtensionsType">
    <xs:annotation>
      <xs:documentation xml:lang="en">Description here.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:element name="TPA_Extensions" type="TPA_ExtensionsType">
    <xs:annotation>
      <xs:documentation xml:lang="en">More description here.</xs:documentation>
    </xs:annotation>
  </xs:element>
</xs:schema>  

I've tried removing the type definition, but it's referenced in a slew of other places.

Could anyone please offer any advice for how to get this to work?

Thanks

Edit:

Here's the lines where the WSDL imports these schemas:

<definitions name='ResLookupGet' targetNamespace='http://org.jboss.ws/resLookupGet' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:http='http://schemas.xmlsoap.org/wsdl/http/' xmlns:mime='http://schemas.xmlsoap.org/wsdl/mime/' xmlns:ns='http://www.opentravel.org/OTA/2003/05/beta' xmlns:rq='http://www.opentravel.org/OTA/2003/05/betarq' xmlns:rs='http://www.opentravel.org/OTA/2003/05/betars' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://org.jboss.ws/resLookupGet' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
 <types>
  <xsd:schema targetNamespace='http://org.jboss.ws/resLookupGet' xmlns:tns='http://org.jboss.ws/resLookupGet' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
   <xsd:import namespace='http://www.opentravel.org/OTA/2003/05/betarq' schemaLocation='./schemas/FooAffiliateHeaderRQ.xsd'/>
   <xsd:import namespace='http://www.opentravel.org/OTA/2003/05/betarq' schemaLocation='./schemas/FooResLookupGetRQ.xsd'/>
   <xsd:import namespace='http://www.opentravel.org/OTA/2003/05/betars' schemaLocation='./schemas/FooResLookupGetRS.xsd'/>
  </xsd:schema>
 </types>
<message name='ResLookupGetRQ'>
  <part element='rq:FooResLookupGetRQ' name='FooResLookupGetRQ'></part>
 </message>
 <message name='ResLookupGetRS'>
  <part element='rs:FooResLookupGetRS' name='FooResLookupGetRS'></part>
 </message>

Answer

Cuga picture Cuga · Aug 9, 2012

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

The reasoning for it is wsimport is trying to generate classes in the same package with the same name and/or methods, which it obviously cannot do.

So by omitting the forced package declaration, wsimport is able to put the classes in whatever packages it wants, which turns out to be 3 different packages per the <xsd:schema> definition in the WSDL.

Thanks again @Petru!