0

我正在尝试为 PHP SOAP 服务器编写一个 java SOAP 客户端。为了更容易开始,我想通过 wsdl2java 生成 java 类,但不幸的是,我从 wsdl2java 收到以下错误。

[编辑] 我忘了提到,我使用 Axis2 1.6.2 中的 wsdl2java 来生成 java 类。[/编辑]

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

这是我的 wsdl 文件:

<?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>

我已经搜索了 stackoverflow 和其他各种页面,但找不到任何有用的东西。如果有人可以帮助我解决这个问题,那就太好了。

问候内森

[编辑]

我尝试使用 Apache CXF 验证器验证 WSDL。它抛出以下错误:

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.
4

3 回答 3

1
Caused by ... [binding:...] not exist.

通常意味着您的 wsdl 文件中的xmlns:tns和是不同的。targetNamespace

使它们相同,它应该可以工作。

于 2016-01-10T06:57:21.170 回答
0

看来您的标签错过了wsdl:

前任:

<wsdl:definitions ... >
    <wsdl:types>
    </wsdl:types>
</wsdl:definitions>
于 2013-03-18T20:18:07.610 回答
0

wsdl 文件中有一些缺失的属性和一些其他错误。以下文件工作正常。

<?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>
于 2013-03-26T10:34:43.500 回答