Search code examples
javaxmljaxbwsdlwsimport

Getting Property is already defined error from wsimport


I have looked similar solutions from stackoverflow but i couldn't handle it. It says:[ERROR] Property "Any" is already defined. Use <jaxb:property> to resolve this conflict. I created a binding xml to solve the conflict and try to rename "Any" property, it says your XPath is incorrect. But I couldnt find where is the mistake in the path. For better explaining, sharing "wsdl" which i couldn't make any change on it, its external service. Also my binding xml.

Wsdl :

<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri_integration.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri_integration.org/">
    <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri_integration.org/">
            .
            .
            .
            <s:element name="Get_DataSet_Data_With_IDResponse">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="0" maxOccurs="1" name="Get_DataSet_Data_With_IDResult">
                            <s:complexType>
                                <s:sequence>
                                    <s:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax"/>
                                    <s:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1" processContents="lax"/>
                                </s:sequence>
                            </s:complexType>
                        </s:element>
                        <s:element minOccurs="0" maxOccurs="1" name="pref_err" type="s:string"/>
                    </s:sequence>
                </s:complexType>
            </s:element>
        </s:schema>
    </wsdl:types>
</wsdl:definitions>

Binding xml :

<jxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
              xmlns="http://java.sun.com/xml/ns/jaxws"
              xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
              xmlns:s="http://www.w3.org/2001/XMLSchema"
              wsdlLocation="http://10.10.10.10:8080/integration.asmx?wsdl">

    <jxb:bindings
            node="/wsdl:definitions/wsdl:types/s:schema/s:element[@name='Get_DataSet_Data_With_IDResponse']/s:complexType/s:sequence/s:element[@name='Get_DataSet_Data_With_IDResult']/s:complexType/s:sequence/s:any[@namespace='urn:schemas-microsoft-com:xml-diffgram-v1']/s:complexType">
        <jxb:property name="any2"/>
    </jxb:bindings>
</jxb:bindings>

And cmd command like that:

wsimport -clientjar export.jar -b binding.xml http://10.10.10.10:8080/integration.asmx?wsdl

Solution

  • Finally, got the point and solved my problem.

    I have forgot schemaLocation. Also it was the wrong path for the my property.

    There is my binding xml:

    <jxb:bindings version="2.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns="http://java.sun.com/xml/ns/jaxws"
                  xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
                  xmlns:s="http://www.w3.org/2001/XMLSchema"
    >
        <jxb:bindings schemaLocation="http://10.10.10.10:8080/integration.asmx?wsdl#types?schema1"
                      node="//s:element[@name='Get_DataSet_Data_With_IDResponse']/s:complexType/s:sequence/s:element[@name='Get_DataSet_Data_With_IDResult']/s:complexType/s:sequence/s:any[@namespace='urn:schemas-microsoft-com:xml-diffgram-v1']">
            <jxb:property name="any2"/>
        </jxb:bindings>
    </jxb:bindings>