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

4

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.

Ranchod answered 24/4, 2009 at 13:54 Comment(0)
M
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)

Mobley answered 24/4, 2009 at 13:54 Comment(2)
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.Ratel
saved my time.thank you very much.->wsimport -keep -verbose example.wsdl -B-XautoNameResolutionErnieernst
C
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>
Cherub answered 13/3, 2012 at 4:33 Comment(0)
E
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.

Estoppel answered 8/3, 2016 at 23:58 Comment(0)
G
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.

Gamboge answered 24/4, 2009 at 13:57 Comment(1)
This is really not the problem, I used a different -p option.Ranchod

© 2022 - 2024 — McMap. All rights reserved.