[JAVA] wsimport error handling (A class / interface with the same name "xxx" is already in use)

The error message that occurred in wsimport used to automatically generate Soap client code for Java is in Japanese, and I could not find it if it was Japanese information, so I made a detour a little, so remarks.

Error message

In Japanese

[ERROR]Same name"xxxxxx.SampleResponse"class of/The interface is already in use.
Use class customization to resolve this conflict.

In English

[ERROR] A class/interface with the same name "xxx" is already in use. 
Use a class customization to resolve this conflict.

Causes and countermeasures

There are two possible causes.

--Duplicate name due to arbitrary specification of package name by specifying -p option --Duplicate name attribute value in wsdl ... May occur if the server side is .NET (extension asmx)

In the former case, it can be solved by executing wsimport without specifying the -p option (that is, according to wsdl).

In my case it was the latter. Specifically, it seems bad that there is a definition with the same name () like the following SampleResponse. If you delete one of the definitions, the duplicate error disappears, but it ends up being an error because it is referenced by the method.

hoge.wsdl


<s:element name="SampleResponse">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="Response" nillable="true" type="tns:SampleResponse" />
    </s:sequence>
  </s:complexType>
</s:element>
<s:complexType name="SampleResponse">
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="Result" type="tns:SampleResponseResult" />
    <s:element minOccurs="0" maxOccurs="1" name="ApplicationResponse" type="tns:SampleResponseApplicationResponse" />
  </s:sequence>
</s:complexType>

As a countermeasure in this case, specify the following options in the wsimport command. Note that there is no space after -B.

-B-XautoNameResolution

In this case, the classes SampleResponse and SampleResponse2 are generated, so modify them as appropriate.

reference

Recommended Posts

wsimport error handling (A class / interface with the same name "xxx" is already in use)
Invalid route name, already in use: Error resolution for'new_user_session'
`bind': Address already in use --bind (2) for 127.0.0.1:3000 (Errno :: EADDRINUSE) How to deal with the error
Error handling when the maximum file size is exceeded when uploading a file with Spring Boot
How to use the same Mapper class in multiple data sources with Spring Boot + MyBatis
Java learning_Behavior when there is a method with the same name as a field with the same name in two classes that have an inheritance relationship
Exception handling with a fluid interface
Error when the member of Entity class used in SpringWebFlux is final
What is a class in Java language (2 /?)
Be careful when setting the class name when creating a document-based app in Swift
When is it said that you can use try with a Swift error?
Call a method of the parent class by explicitly specifying the name in Ruby
Isn't there a name collision when enum has the same name in the switch statement?
Androd: What to do about "The Realm is already in a write transaction in"
When you get lost in the class name
Java Error Handling Basics-The story that catch is only picked up in the foreground
A warning is displayed when trying to use a huge integer with the special variables $ 1, $ 2, $ 3 ...