razenha
razenha

Reputation: 7742

Problem generating Java SOAP web services client with JDK tool wsimport from a WSDL generated by a .NET 2.0 application

I'm trying to generate a client for some SOAP web services using the JDK 6 tool wsimport. The WSDL was generated by a .NET 2.0 application. For .NET 3.X applications, it works fine.

When I run

wsimport -keep -p mypackage http://myservice?wsdl

it shows several error messages like this:

[ERROR] A class/interface with the same name "mypackage.SomeClass" is already in use. Use a class customization to resolve this conflict. line ?? of http://myservice?wsdl

When I generate the web services client using Axis 1.4 (using the Eclipse WebTools plug-in).

Does anybody know what can I do in order to use the wsimport tool? I really don't understand what the "class customization" thing is.

Upvotes: 42

Views: 39830

Answers (4)

Margaret Lydon
Margaret Lydon

Reputation: 221

For anyone reading this using maven, this is how to add it to the .pom file. Note the args in the configuration section. This is not very easily found in documentation. Many thanks to Isaac Stephens for his help with this.

<!-- definition for ERPStandardWork service -->
<execution>
  <id>ERPStandardWorkService</id>
  <goals>
    <goal>wsimport</goal>
  </goals>
  <configuration>
    <!-- this resolves naming conflicts within the wsdl - there are several copies of fault report objects which clash otherwise. -->
    <args>
       <arg>-B-XautoNameResolution</arg>
    </args>
    <wsdlDirectory>${basedir}/src/main/resources/META-INF/wsdl</wsdlDirectory>
    <wsdlFiles>
        <wsdlFile>ERPStandardWork.wsdl</wsdlFile>
    </wsdlFiles>
      <wsdlLocation>${basedir}/src/main/resources/META-INF/wsdl/ERPStandardWork.wsdl
    </wsdlLocation>
    <staleFile>${project.build.directory}/jaxws/ERPStandardWork/.staleFlag
    </staleFile>
  </configuration>
</execution>

Upvotes: 22

aram063
aram063

Reputation: 1133

The accepted answer above would solve your problem but wouldnt fix the underlying cause.

The issue is happening because an operation in your wsdl file has the same name as an xsd:complexType in your xsd file - like the example below. All types and operations should have unique names.

<xsd:complexType name="SearchDocuments">
      <xsd:sequence>
        <xsd:element name="document" type="ns0:SearchDocumentById" maxOccurs="unbounded"/>
      </xsd:sequence>
</xsd:complexType>

<operation name="SearchDocuments">
      <input wsam:Action="http://controller.xxx.xxx.com/DocumentWS/searchDocumentsRequest" message="tns:searchDocumentsRequest"/>
      <output wsam:Action="http://controller.xxx.xxx.com/DocumentWS/searchDocumentsResponse" message="tns:searchDocumentsResponse"/>
</operation>

So check your operations and types. Make sure none of them have the same name i.e. no duplicate names.

Upvotes: 1

PaulH
PaulH

Reputation: 618

I don't know if this was ever solved, but I spent some time googling for a solution to this same problem.

I found a fix here - https://jax-ws.dev.java.net/issues/show_bug.cgi?id=228

The solution is to run wsimport with the -B-XautoNameResolution (no spaces)

Upvotes: 95

simon
simon

Reputation: 12912

You are possibly generating all the classes from the WSDL file in the same package. If that is the case, try specifying a different target package for each WSDL file with the -p option of wsimport.

Upvotes: 0

Related Questions