2009-09-26 52 views
0

我有WSDL文件製作SOAP請求,使用,我想使SOAP請求,這將看起來完全一樣 -如何添加標題,同時使用SOAPpy的

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
    <AuthSoapHd xmlns="http://foobar.org/"> 
     <strUserName>string</strUserName> 
     <strPassword>string</strPassword> 
    </AuthSoapHd> 
    </soap:Header> 
    <soap:Body> 
    <SearchQuotes xmlns="http://foobar.org/"> 
     <searchtxt>string</searchtxt> 
    </SearchQuotes> 
    </soap:Body> 
</soap:Envelope> 

來解答這個問題,我這樣做

>> from SOAPpy import WSDL 
>> WSDLFILE = '/path/foo.wsdl' 
>> server = WSDL.Proxy(WSDLFILE) 
>> server.SearchQuotes('rel') 

我得到這個錯誤

faultType: <Fault soap:Server: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. 

的我調試,並得到這個

*** Outgoing SOAP ****************************************************** 
<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope 
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/1999/XMLSchema" 
> 
<SOAP-ENV:Body> 
<SearchQuotes SOAP-ENC:root="1"> 
<v1 xsi:type="xsd:string">rel</v1> 
</SearchQuotes> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

我們可以看到它不包含任何標題。我認爲WSDL文件有一些錯誤。 現在,任何人都可以建議我如何添加標題到這個即將離任的肥皂請求。

任何形式的幫助將不勝感激。在此先感謝

回答

0

沒有測試,但我相信你可以使用the docs建議加上肥皂頭,即製作和預習一個SOAPpy.Header實例的方法,然後用server = server._hd (hd)得到裝有它的代理(儘管在你的情況下似乎是破壞WSDL的解決方法,正如你所說 - 修正WSDL可能更好嗎?)。

相關問題