2011-06-28 67 views
3

我一直在遇到SOAP請求標題表示的一些問題。我想我錯過了一些東西。如何基於WSDL文件構建SOAP標題名稱空間

我的(部分)的WSDL看起來是這樣的:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
        xmlns:aws="http://xml.xxx.com" 
        xmlns:security_authenticate_6_1="http://xml.xxx.com/VLSSLQ_06_1_1A" 
        xmlns:security_authenticatereply_6_1="http://xml.xxx.com/VLSSLR_06_1_1A" 
        targetNamespace="http://xml.xxx.com"> 
    <wsdl:types> 
    <xsd:schema targetNamespace="http://xml.xxx.com"> 
     <xsd:import namespace="http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd" schemaLocation="WBS_Session-2.0.xsd"/>  
     <xsd:import namespace="http://xml.xxx.com/VLSSLQ_06_1_1A" schemaLocation="Security_Authenticate_06_1_1A.xsd"/> 
     <xsd:import namespace="http://xml.xxx.com/VLSSLR_06_1_1A" schemaLocation="Security_AuthenticateReply_06_1_1A.xsd"/> 
    </xsd:schema> 
    </wsdl:types> 
    <wsdl:message name="Session" xmlns:ns0="http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd"> 
    <wsdl:part name="Session" element="ns0:Session"/> 
    </wsdl:message> 
    <wsdl:message name="Security_Authenticate_6_1"> 
    <wsdl:part name="Security_Authenticate_6_1" element="security_authenticate_6_1:Security_Authenticate"/> 
    </wsdl:message> 
    <wsdl:message name="Security_AuthenticateReply_6_1"> 
    <wsdl:part name="Security_AuthenticateReply_6_1" element="security_authenticatereply_6_1:Security_AuthenticateReply"/> 
    </wsdl:message> 
    <wsdl:portType name="XXXWebServicesPT">  
    <wsdl:operation name="Security_Authenticate"> 
     <wsdl:input message="aws:Security_Authenticate_6_1"/> 
     <wsdl:output message="aws:Security_AuthenticateReply_6_1"/> 
    </wsdl:operation>  
    </wsdl:portType> 
    <wsdl:binding name="XXXWebServicesBinding" type="aws:XXXWebServicesPT"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>  
    <wsdl:operation name="Security_Authenticate"> 
     <soap:operation soapAction="http://webservices.xxx.com/1ASIWJTUTUA/VLSSLQ_06_1_1A"/> 
     <wsdl:input> 
     <soap:header message="aws:Session" part="Session" use="literal"/> 
     <soap:body use="literal"/> 
     </wsdl:input> 
     <wsdl:output> 
     <soap:header message="aws:Session" part="Session" use="literal"/> 
     <soap:body use="literal"/> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="XXXWebServices"> 
    <wsdl:port name="XXXWebServicesPort" binding="aws:XXXWebServicesBinding"> 
     <soap:address location="https://test.webservices.xxx.com"/> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

我想訪問Security_Authenticate行動,在這種情況下,頭必須看起來像:

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> 
    <soapenv:Header> 
     <wbs:Session xmlns:wbs='http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd'> 
     <wbs:SessionId></wbs:SessionId> 
     <wbs:SequenceNumber></wbs:SequenceNumber> 
     <wbs:SecurityToken></wbs:SecurityToken> 
     </wbs:Session> 
    </soapenv:Header> 
    <soapenv:Body> 
     <vls:Security_Authenticate> 
     <vls:tagX> 
      <vls:tagY>yyy</vls:tagY> 
      <vls:tagZ>Z</vls:tagZ> 
     </vls:tagX> 
     </vls:Security_Authenticate> 
    </soapenv:Body> 
</soapenv:Envelope> 

我應該如何建我的soapenvelope和我的頭文件命名空間?

謝謝。

+0

你解決呢?我認爲我有同樣的錯誤,使用相同的Web服務(如果您更改xxx作爲公司的名稱,則命名空間適合)您是否找到解決此問題的方法?我的一個是在VB.NET中完成的,我使用的是公司自己創建的Web服務,所以它不應該有任何錯誤。我沒有手動創建我的SOAP請求,所以我不知道... – 2011-07-22 13:58:34

+1

我使用SOAP(ruby gem來構建和處理肥皂消息)並將操作指定爲蛇情況來解決,例如,如果操作名稱是:ActionNameTest,我不得不稱之爲「action_name_test」。它爲我工作.... – content01

+0

可以請你詳細解釋你的解決方案。我面臨同樣的問題。 – wib

回答

1

你有你的XSD使用對象之前聲明命名空間,所以在你的情況下,使用Session對象:

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> 
    <soapenv:Header> 
    <wbs:Session xmlns:wbs='http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd'> 
     <wbs:SessionId></wbs:SessionId> 
     <wbs:SequenceNumber></wbs:SequenceNumber> 
     <wbs:SecurityToken></wbs:SecurityToken> 
    </wbs:Session> 
    </soapenv:Header> 
    ... 
+1

我不斷收到此消息:(肥皂:客戶端)12 |演示|肥皂消息標題不正確(在軌道上的紅寶石)。但是,如果我複製粘貼我的XML請求並在soapUI上運行它,我會得到正確的響應,而且沒有任何錯誤! – content01

+0

我不太瞭解ROR可能會做什麼。我認爲你正確地聲明瞭你的soapenv命名空間。也許在你的問題中發佈完整的XML? – dandrews

+0

當然...看看我的編輯完整的XML – content01