2013-03-13 37 views
0

我正在尝试为PHP SOAP服务器编写一个java SOAP客户端。为了更容易的开始,我想通过wsdl2java生成java类,但不幸的是,我从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> 
我已经搜查计算器和各种其他的网页,但找不到任何有用的

。如果有人能够帮助我解决这个问题,这将非常棒。

问候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

曾在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> 
0

看来你的标签错过wsdl:

例:

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

我不认为我需要在每个wsdl标签上写这个,因为我已经为wsdl定义了名称空间而没有前缀:'xmlns =“http://schemas.xmlsoap.org/wsdl/”'但是我会尝试这个,看看它是否有帮助。 – Neithan 2013-03-19 08:28:01

+0

我已经为所有wsdl相关标签添加了命名空间wsdl,并且没有任何更改。我从wsdl2java收到同样的错误。 – Neithan 2013-03-19 12:50:02

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

通常意味着在您的WSDL文件的xmlns:tnstargetNamespace是不同的。

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