【问题标题】:python soappy add header蟒蛇肥皂添加标题
【发布时间】:2009-12-06 23:13:08
【问题描述】:
我有以下 PHP 示例代码:
$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);
我的问题:SoapHeader() 和 __setSoapHeaders() 部分的 SOAPpy 等效项是什么?
相关问题
【问题讨论】:
标签:
python
soap
header
soappy
【解决方案1】:
这是一个使用suds 库(SOAPpy 的替代方案)的示例。它假定自定义标头未在 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)