我正在尝试为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和其他各种页面,但找不到任何有用的东西。如果有人能帮助我解决这个问题,真的很棒。
问候Neithan
[编辑]
我尝试使用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.
答案 0 :(得分:1)
Caused by ... [binding:...] not exist.
通常表示wsdl文件中的xmlns:tns
和targetNamespace
不同。
使它们相同,它应该有用。
答案 1 :(得分:0)
您的代码似乎错过了wsdl:
例如:
<wsdl:definitions ... >
<wsdl:types>
</wsdl:types>
</wsdl:definitions>
答案 2 :(得分: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>