Cuga
Cuga

Reputation: 17904

wsimport - Two declarations cause a collision, same line given

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>

Upvotes: 23

Views: 36073

Answers (2)

Jas Singh
Jas Singh

Reputation: 21

I had the same issue and I was calling webservice through pom.xml. I just removed packageName and defined a sourceDestDir. This will create stubs inside source packages. I am taking wsdlURL from a config. Here are the changes I did in pom.xml:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <execution>
                <id>wsimport-from-jdk</id>
                <goals>
                    <goal>wsimport</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <args>
                <arg>-B-XautoNameResolution</arg>
            </args>
            <wsdlUrls>
                <wsdlUrl>${service.wsdl.url}</wsdlUrl> 
            </wsdlUrls>
            <keep>true</keep> 
            <sourceDestDir>src/main/java</sourceDestDir>
        </configuration>
    </plugin>

Upvotes: 0

Cuga
Cuga

Reputation: 17904

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!

Upvotes: 33

Related Questions