42

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.

Eddie
  • 53,828
  • 22
  • 125
  • 145
razenha
  • 7,660
  • 6
  • 37
  • 53

4 Answers4

95

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)

PaulH
  • 618
  • 1
  • 10
  • 12
  • The problem solved by adding this code behind the `wsimport` command. But the root of this problem for me, there are two different type with adjoining `XResponse` and with underscore `X_Response` so it occurs name conflict, if naming would be understandable like `XResponse` and `XResponseDefinition`, it will be no problem. – fiskra Jul 18 '17 at 11:41
  • saved my time.thank you very much.->`wsimport -keep -verbose example.wsdl -B-XautoNameResolution` – Akhil Babu Korkandi Nov 28 '19 at 09:20
22

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>
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Margaret Lydon
  • 221
  • 2
  • 2
1

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.

aram063
  • 1,067
  • 13
  • 19
0

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.

simon
  • 12,666
  • 26
  • 78
  • 113