3

We are trying to generate a Java SOAP client from to integrate with an external service. Since this is an external company, changes to the WSDL is not an option.

When trying to generate the client using the cxf-codegen-plugin Maven plugin, we get the following error:

Two declarations cause a collision in the ObjectFactory class.

The problem relates to the following declaration in the WSDL:

<s:element name="CallSomeMethod">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" name="GetSomeDataResult" type="tns:InterfaceReturnCode" />
        <s:element minOccurs="0" maxOccurs="1" name="getSomeDataResult" type="tns:GetSomeDataResult" />
      </s:sequence>
    </s:complexType>
  </s:element>

It's obvious to see where the issue is. My problem is, the WSDL seems to get imported fine by online generic SOAP clients, so it has to at least be valid. I have also read that generating the Java code without the -p option will result in the generator creating separate packages, which should resolve the issue. But, how can I do this with the cxf-codegen-plugin Maven plugin?

Nico Huysamen
  • 10,217
  • 9
  • 62
  • 88

1 Answers1

0

Not sure if you found the solution or not but might help someone else. I have tried the following and it works for me. I use cxf-codegen-plugin Maven plugin and got the above error. So first I used -autoNameResolution in my pom.xml. This resolved few duplicates but still had few. So in my pom.xml I used the "-p" argument to put the conflicting namespaces in separate directories and it worked.

Example (snippetfrom my pom.xml):

<wsdlOption>

<wsdl>${basedir}/src/main/resources/wsdl/<wsdl_file>.wsdl</wsdl>

<wsdlLocation>http://host.does.not.exist/src/main/resources/wsdl/<wsdl_file>.wsdl</wsdlLocation>
                                    <extraargs>
                                        <extaarg>-client</extaarg>
                                        <extaarg>-verbose</extaarg>
                                        <extraarg>-autoNameResolution</extraarg>

                                        <extraarg>-p</extraarg>
                                        <extraarg><conflicting_namespace>=<package_where_the_namepsace_should_get_created></extraarg>
                                        <extraarg>-p</extraarg>
                                        <extraarg><conflicting_namespace>=<package_where_the_namepsace_should_get_created></extraarg>
                                    </extraargs>
                                    <packagenames>
                                        <packagename><path_to_package></packagename>
                                    </packagenames>
                              </wsdlOption>
Adi
  • 81
  • 1
  • 2