开发者

python soappy add header

I have the following PHP example code:

$client = new SoapClient("http://example.com/example.wsdl");

$h = Array();
array_push($h, new SoapHeader("http://example2.com/example2/", "h", "v"));
$client->__setSoapHeaders($h);

$s = $client->__soapCall('Op', $data);

My question: what's the SOAPpy equivalent for the SoapHeader() and __setSoapHeaders() part?

Related 开发者_JAVA技巧question

  • How to add header while making soap request using soappy


Here's an example using suds library (an alternative to SOAPpy). It assumes that the custom header is not defined in the wsdl.

from suds.client      import Client
from suds.sax.element import Element

client = Client("http://example.com/example.wsdl")

# <tns:h xmlns:tns="http://example2.com/example2/">v</tns:h>
tns = ("tns", "http://example2.com/example2/")
h = Element('h', ns=tns).setText('v')
client.set_options(soapheaders=h) 
#
s = client.service.Op(data)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜