2011-07-05 50 views
0

我使用這個WSDL文件來描述我的web服務:WSDL用肥皂-RPC風格不編譯

<?xml version="1.0" encoding="UTF-8" ?> 
<wsdl:definitions targetNamespace="http://www.myapproach.de/knowledgebase" name="Knowledgebase" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://www.myapproach.de/knowledgebase" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" 
    xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
    xmlns:rq="http://www.myapproach.de/knowledgebase"> 

    <wsdl:types> 
    <xsd:schema> 
     <xsd:import namespace="http://www.myapproach.de/knowledgebase" schemaLocation="GetValueRequest.xsd"/> 
    </xsd:schema> 
    </wsdl:types> 

    <wsdl:message name="getValueForKey"> 
     <wsdl:part name="parameters" element="rq:getValueForKey" /> 
    </wsdl:message> 
    <wsdl:message name="getValueForKeyResponse"> 
     <wsdl:part name="parameters" element="rq:getValueForKeyResponse" /> 
    </wsdl:message> 

    <wsdl:portType name="KnowledgebasePortType"> 
     <wsdl:operation name="getValueForKey"> 
      <wsdl:input message="tns:getValueForKey" /> 
      <wsdl:output message="tns:getValueForKeyResponse" /> 
     </wsdl:operation> 
    </wsdl:portType> 

    <wsp:Policy wsu:Id="KnowledgebasePortBinding_WSAM_Addressing_Policy"> 
     <wsam:Addressing wsp:Optional="true"> 
      <wsp:Policy /> 
     </wsam:Addressing> 
    </wsp:Policy> 

    <wsdl:binding name="KnowledgebasePortBinding" type="tns:KnowledgebasePortType"> 
     <wsaw:UsingAddressing /> 
     <wsp:PolicyReference URI="#KnowledgebasePortBinding_WSAM_Addressing_Policy" /> 
     <!-- http://www.w3.org/2003/05/soap/bindings/HTTP/ --> 
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" /> 
     <wsdl:operation name="getValueForKey"> 
      <soap:operation soapAction="http://www.myapproach.de/knowledgebase/getValueForKey" /> 
      <wsdl:input> 
       <soap:body use="literal" /> 
      </wsdl:input> 
      <wsdl:output> 
       <soap:body use="literal" /> 
      </wsdl:output> 
     </wsdl:operation> 
    </wsdl:binding> 

    <wsdl:service name="Knowledgebase"> 
     <wsdl:port name="KnowledgebasePortType" binding="tns:KnowledgebasePortBinding"> 
      <soap:address location="http://www.myapproach.de/knowledgebase" /> 
     </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

GetValueRequest.xsd

<?xml version="1.0" encoding="UTF-8"?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://www.myapproach.de/knowledgebase" xmlns:tns="http://www.myapproach.de/knowledgebase"> 

    <xsd:element name="getValueForKey" type="tns:getValueForKey" /> 
    <xsd:complexType name="getValueForKey"> 
     <xsd:sequence> 
      <xsd:element name="arg0" type="xsd:string" minOccurs="0" /> 
      <xsd:element name="arg1" type="xsd:string" minOccurs="0" /> 
      <xsd:element name="arg2" type="xsd:double"></xsd:element> 
     </xsd:sequence> 
    </xsd:complexType> 

    <xsd:element name="getValueForKeyResponse" type="tns:getValueForKeyResponse" /> 
    <xsd:complexType name="getValueForKeyResponse"> 
     <xsd:sequence> 
      <xsd:element name="return" type="xsd:string" minOccurs="0" /> 
     </xsd:sequence> 
    </xsd:complexType> 

</xsd:schema> 

每次我跑wsimport,我得到此錯誤:

[wsimport] parsing WSDL... 
[wsimport] [ERROR] Invalid wsdl:operation "getValueForKey": its a rpc-literal operation, message part must refer to a schema type declaration 
[wsimport] line 27 of file:/path/MyFile.wsdl 

我已經將getValueForKey類型導出到xsd-schemafile,所以我不明白這個e RROR ......我想這個SH ***整天GRML

回答

1

張貼的問題後不久,我找到了答案:-)

而不是

<wsdl:message name="getValueForKey"> 
     <wsdl:part name="parameters" element="rq:getValueForKey" /> 
</wsdl:message> 

使用本

<wsdl:message name="getValueForKey"> 
     <wsdl:part name="parameters" type="rq:getValueForKey" /> 
</wsdl:message> 

必須使用屬性「type」而不是「element」。

此外肥皂:body元素必須有一個命名空間

<wsdl:input> 
     <soap:body use="literal" namespace="YourNormalNamespace" /> 
</wsdl:input> 
0

總之,WSDL部分必須具有在web服務否則它必須是文檔樣式的RPC風格的情況下