简体   繁体   中英

wsdl2java error on generating the java classes

I'm trying to write a java SOAP client for a PHP SOAP server. For an easier start I would like to generate the java classes via wsdl2java, but unfortunately I'm getting the following error from wsdl2java.

[edit] I forgot to mention, that I'm using wsdl2java from Axis2 1.6.2 to generate the java classes. [/edit]

I:\>axis2\bin\wsdl2java -uri i:\axis2\result\tatoo.wsdl -o i:\axis2\result -d adb -s
Using AXIS2_HOME:   i:\axis2
Using JAVA_HOME:    c:\Program Files\Java\jdk1.6.0_33
Retrieving document at 'i:\axis2\result\tatoo.wsdl'.
log4j:WARN No appenders could be found for logger (org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing WSDL
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:175)
        at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
        at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: org.apache.axis2.AxisFault
        at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
        at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateService(WSDL11ToAxisServiceBuilder.java:411)
        at org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder.populateAllServices(WSDL11ToAllAxisServicesBuilder.java:107)
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:169)
        ... 2 more
Caused by: java.lang.NullPointerException
        at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.findBinding(WSDL11ToAxisServiceBuilder.java:1084)
        at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateService(WSDL11ToAxisServiceBuilder.java:341)
        ... 4 more

Here is my wsdl file:

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="TatooWebserviceDefinition" xmlns:tns="http://wafriv.de/tatoo_webservice/wsdl.php" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
    <types>
        <xsd:schema>
            <xsd:complexType name="gameList">
                <xsd:sequence>
                    <xsd:element name="game" type="game" minOccurs="1" maxOccurs="unbounded" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="game">
                <xsd:sequence>
                    <xsd:element name="name" type="xsd:string" />
                    <xsd:element name="version" type="xsd:integer" />
                    <xsd:element name="edition" type="xsd:integer" />
                    <xsd:element name="gameID" type="xsd:string" />
                    <xsd:element name="creator" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="codexList">
                <xsd:sequence>
                    <xsd:element name="codex" type="codex" minOccurs="1" maxOccurs="unbounded" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="codex">
                <xsd:sequence>
                    <xsd:element name="name" type="xsd:string" />
                    <xsd:element name="version" type="xsd:integer" />
                    <xsd:element name="edition" type="xsd:integer" />
                    <xsd:element name="codexID" type="xsd:string" />
                    <xsd:element name="creator" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </types>
    <message name="gameUploadRequest">
        <part name="name" type="xsd:string" />
        <part name="gameID" type="xsd:string" />
        <part name="version" type="xsd:integer" />
        <part name="edition" type="xsd:integer" />
        <part name="creator" type="xsd:string" />
        <part name="createDateTime" type="xsd:dateTime" />
        <part name="gameData" type="xsd:string" />
    </message>
    <message name="gameUploadResponse">
        <part name="response" type="xsd:string" />
    </message>
    <message name="codexUploadRequest">
        <part name="name" type="xsd:string" />
        <part name="gameID" type="xsd:string" />
        <part name="gameVersion" type="xsd:integer" />
        <part name="gameEdition" type="xsd:integer" />
        <part name="codexID" type="xsd:string" />
        <part name="version" type="xsd:integer" />
        <part name="edition" type="xsd:integer" />
        <part name="creator" type="xsd:string" />
        <part name="createDateTime" type="xsd:dateTime" />
        <part name="codexData" type="xsd:string" />
    </message>
    <message name="codexUploadResponse">
        <part name="response" type="xsd:string" />
    </message>
    <message name="getGameListRequest">
        <part name="versions" type="xsd:string" />
    </message>
    <message name="getGameListResponse">
        <part name="gameList" type="tns:gameList" />
    </message>
    <message name="getCodexListRequest">
        <part name="gameID" type="xsd:string" />
        <part name="gameVersion" type="xsd:integer" />
        <part name="gameEdition" type="xsd:integer" />
        <part name="versions" type="xsd:string" />
    </message>
    <message name="getCodexListResponse">
        <part name="codexList" type="tns:codexList" />
    </message>
    <message name="getGameRequest">
        <part name="gameID" type="xsd:string" />
        <part name="version" type="xsd:integer" />
        <part name="edition" type="xsd:integer" />
    </message>
    <message name="getGameResponse">
        <part name="gameData" type="xsd:string" />
    </message>
    <message name="getCodexRequest">
        <part name="codexID" type="xsd:string" />
        <part name="version" type="xsd:integer" />
        <part name="edition" type="xsd:integer" />
    </message>
    <message name="getCodexResponse">
        <part name="codexData" type="xsd:string" />
    </message>
    <portType name="TatooWebservicePortType">
        <operation name="gameUpload">
            <input message="gameUploadRequest" />
            <output message="gameUploadResponse" />
        </operation>
        <operation name="codexUpload">
            <input message="codexUploadRequest" />
            <output message="codexUploadResponse" />
        </operation>
        <operation name="getGameList">
            <input message="getGameListRequest" />
            <output message="getGameListResponse" />
        </operation>
        <operation name="getCodexList">
            <input message="getCodexListRequest" />
            <output message="getCodexListResponse" />
        </operation>
        <operation name="getGame">
            <input message="getGameRequest" />
            <output message="getGameResponse" />
        </operation>
        <operation name="getCodex">
            <input message="getCodexRequest" />
            <output message="getCodexResponse" />
        </operation>
    </portType>
    <binding name="TatooWebserviceBinding" type="tns:TatooWebservicePortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
        <operation name="gameUpload">
            <soap:operation soapAction="urn:gameUpload" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="codexUpload">
            <soap:operation soapAction="urn:codexUpload" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="getGameList">
            <soap:operation soapAction="urn:getGameList" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="getCodexList">
            <soap:operation soapAction="urn:getCodexList" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="getGame">
            <soap:operation soapAction="urn:getGame" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="getCodex">
            <soap:operation soapAction="urn:getCodex" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
    </binding>
    <service name="TatooWebservice">
        <port name="TatooWebservicePort" binding="tns:TatooWebserviceBinding">
            <soap:address location="http://wafriv.de/tatoo_webservice/index.php" />
        </port>
    </service>
</definitions>

I've already searched stackoverflow and various other pages but can't find anything helpful. It would be really great if anybody can help me with this problem.

Greetings Neithan

[edit]

I tried to validate the WSDL with the Apache CXF validator. It throws the following error:

WSIBP Validator found <{http://wafriv.de/tatoo_webservice/wsdl.php}blaBinding> is NOT a SOAP binding
WSDLValidator Error :
 Summary:  Failures: 1, Warnings: 0

 <<< ERROR!
file:/c:/Users/Neithan/Desktop/bla/tatoo.wsdl:[214,3]
 Caused by {http://wafriv.de/tatoo_webservice/wsdl.php}[binding:blaBinding] not exist.
Caused by ... [binding:...] not exist.

usually means that the xmlns:tns and targetNamespace in your wsdl file are different.

Make them the same and it should work.

It seems your tags miss the wsdl:

Ex:

<wsdl:definitions ... >
    <wsdl:types>
    </wsdl:types>
</wsdl:definitions>

Had some missing attributes and some other errors in the wsdl file. The following file works fine.

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="TatooWebserviceDefinition" targetNamespace="http://wafriv.de/tatoo_webservice/wsdl.php"
             xmlns:tns="http://wafriv.de/tatoo_webservice/wsdl.php"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:x1="http://wafriv.de/tatoo_webservice/wsdl.php/types/"
             xmlns="http://schemas.xmlsoap.org/wsdl/">
    <types>
        <xsd:schema targetNamespace="http://wafriv.de/tatoo_webservice/wsdl.php/types/"
                    xmlns="http://wafriv.de/tatoo_webservice/wsdl.php/types/">
            <xsd:complexType name="gameList">
                <xsd:sequence>
                    <xsd:element name="game" type="game" minOccurs="1" maxOccurs="unbounded" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="game">
                <xsd:sequence>
                    <xsd:element name="name" type="xsd:string" />
                    <xsd:element name="version" type="xsd:integer" />
                    <xsd:element name="edition" type="xsd:integer" />
                    <xsd:element name="gameID" type="xsd:string" />
                    <xsd:element name="creator" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="codexList">
                <xsd:sequence>
                    <xsd:element name="codex" type="codex" minOccurs="1" maxOccurs="unbounded" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="codex">
                <xsd:sequence>
                    <xsd:element name="name" type="xsd:string" />
                    <xsd:element name="version" type="xsd:integer" />
                    <xsd:element name="edition" type="xsd:integer" />
                    <xsd:element name="codexID" type="xsd:string" />
                    <xsd:element name="creator" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </types>
    <message name="gameUploadRequest">
        <part name="name" type="xsd:string" />
        <part name="gameID" type="xsd:string" />
        <part name="version" type="xsd:integer" />
        <part name="edition" type="xsd:integer" />
        <part name="creator" type="xsd:string" />
        <part name="createDateTime" type="xsd:dateTime" />
        <part name="gameData" type="xsd:string" />
    </message>
    <message name="gameUploadResponse">
        <part name="response" type="xsd:string" />
    </message>
    <message name="codexUploadRequest">
        <part name="name" type="xsd:string" />
        <part name="gameID" type="xsd:string" />
        <part name="gameVersion" type="xsd:integer" />
        <part name="gameEdition" type="xsd:integer" />
        <part name="codexID" type="xsd:string" />
        <part name="version" type="xsd:integer" />
        <part name="edition" type="xsd:integer" />
        <part name="creator" type="xsd:string" />
        <part name="createDateTime" type="xsd:dateTime" />
        <part name="codexData" type="xsd:string" />
    </message>
    <message name="codexUploadResponse">
        <part name="response" type="xsd:string" />
    </message>
    <message name="getGameListRequest">
        <part name="versions" type="xsd:string" />
    </message>
    <message name="getGameListResponse">
        <part name="gameList" type="x1:gameList" />
    </message>
    <message name="getCodexListRequest">
        <part name="gameID" type="xsd:string" />
        <part name="gameVersion" type="xsd:integer" />
        <part name="gameEdition" type="xsd:integer" />
        <part name="versions" type="xsd:string" />
    </message>
    <message name="getCodexListResponse">
        <part name="codexList" type="x1:codexList" />
    </message>
    <message name="getGameRequest">
        <part name="gameID" type="xsd:string" />
        <part name="version" type="xsd:integer" />
        <part name="edition" type="xsd:integer" />
    </message>
    <message name="getGameResponse">
        <part name="gameData" type="xsd:string" />
    </message>
    <message name="getCodexRequest">
        <part name="codexID" type="xsd:string" />
        <part name="version" type="xsd:integer" />
        <part name="edition" type="xsd:integer" />
    </message>
    <message name="getCodexResponse">
        <part name="codexData" type="xsd:string" />
    </message>
    <portType name="TatooWebservicePortType">
        <operation name="gameUpload">
            <input message="tns:gameUploadRequest" />
            <output message="tns:gameUploadResponse" />
        </operation>
        <operation name="codexUpload">
            <input message="tns:codexUploadRequest" />
            <output message="tns:codexUploadResponse" />
        </operation>
        <operation name="getGameList">
            <input message="tns:getGameListRequest" />
            <output message="tns:getGameListResponse" />
        </operation>
        <operation name="getCodexList">
            <input message="tns:getCodexListRequest" />
            <output message="tns:getCodexListResponse" />
        </operation>
        <operation name="getGame">
            <input message="tns:getGameRequest" />
            <output message="tns:getGameResponse" />
        </operation>
        <operation name="getCodex">
            <input message="tns:getCodexRequest" />
            <output message="tns:getCodexResponse" />
        </operation>
    </portType>
    <binding name="TatooWebserviceBinding" type="tns:TatooWebservicePortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
        <operation name="gameUpload">
            <soap:operation soapAction="urn:gameUpload" style="rpc" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="codexUpload">
            <soap:operation soapAction="urn:codexUpload" style="rpc" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="getGameList">
            <soap:operation soapAction="urn:getGameList" style="rpc" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="getCodexList">
            <soap:operation soapAction="urn:getCodexList" style="rpc" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="getGame">
            <soap:operation soapAction="urn:getGame" style="rpc" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
        <operation name="getCodex">
            <soap:operation soapAction="urn:getCodex" style="rpc" />
            <input>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </input>
            <output>
                <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:xmethodsTatooWebservice"
                    use="encoded" />
            </output>
        </operation>
    </binding>
    <service name="TatooWebservice">
        <documentation>WSDL for the tatoo webservice</documentation>
        <port name="TatooWebservicePort" binding="tns:TatooWebserviceBinding">
            <soap:address location="http://wafriv.de/tatoo_webservice/index.php" />
        </port>
    </service>
</definitions>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM