2

I'm facing a problem when integrating a third party web service. I receive the following error: [ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.4.2:wsdl2java (generate-sources) on project pcm_portal: Thrown by JAXB: 'string15' is already defined at line 305 column 2 of schema ... -> [Help 1]

Actually I understand the error, this file contains severall schemas for the same target namespace and we can find the same simpleType (string15) defined in both schemas.

It's something like this:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://siebel.com/CustomUI" ...>
    <types>
        <!-- ... -->
        <xsd:schema elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            targetNamespace="http://myNs/"
            xmlns:xsdLocal3="http://myNs/">
            <!-- ... -->
            <xsd:simpleType name="string15">
                <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="15"></xsd:maxLength>
                </xsd:restriction>
            </xsd:simpleType>
            <!-- ... -->
        </xsd:schema>
        <!-- ... -->

        <xsd:schema elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            targetNamespace="http://myNs/"
            xmlns:xsdLocal3="http://myNs/">
            <!-- ... -->
            <xsd:simpleType name="string15">
                <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="15"></xsd:maxLength>
                </xsd:restriction>
            </xsd:simpleType>
            <!-- ... -->
        </xsd:schema>
        <!-- ... -->
    </types>
</definitions>

My question is

1) is there a way to allow wsdl2java to deal with such a file?

Today I'm using it via maven cxf-codegen-plugin and it is configured with this:

<defaultOptions>
    <extraargs>
        <extraarg>-exsh</extraarg>
        <extraarg>true</extraarg>
        <extraarg>-xjc-npa</extraarg>
    </extraargs>
</defaultOptions>

2) If not does anybody knows a reference document that could be an argument for me since the team that gave me the wsdl say that there is no problem (indeed SoapUI makes no trouble with this WSDL)?

scherzoteller
  • 127
  • 1
  • 3
  • 7
  • http://stackoverflow.com/questions/6681265/is-there-a-way-to-deal-with-duplicate-element-definitions-across-multiple-xsd-f this might help you out or even this http://cxf.apache.org/cxf-xjc-plugin.html – Karthik Prasad Jul 23 '14 at 13:14
  • Thank you for your answer, that's actually very close to my problem. Well I'm not sure the workarounds will apply, since my duplicates are in the same wsdl file (that would like to unmodified/unsplitted). – scherzoteller Jul 23 '14 at 14:02
  • How did you solved this? Facing the same issue. – ronnyfm Aug 04 '16 at 23:39
  • Hello, There's not real solution unfortunatly. The wsdl is really invalid and cannot be treated as is. I had to modify it to remove duplicated entries. – scherzoteller Aug 31 '16 at 13:01

1 Answers1

0

I have been the same problem in the past.

I excluded the generation of the schemas from "cxf-codegen-plugin"

e.g.

<extraarg>-nexclude</extraarg>
<extraarg>http://myNs/</extraarg>

I extracted the schema in another file (XSD), and I used "maven-plugin-jaxb2" to generate them.

Obviously you can not declare two identical objects with the same namespace, so you must merge the schemas with the same namespace.

I hope this solution can help to solve your problem.

Xstian
  • 8,184
  • 10
  • 42
  • 72