python soappy 添加头部信息
我有以下的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);
我的问题是:SOAPpy中,SoapHeader()和__setSoapHeaders()的对应部分是什么?
相关问题
1 个回答
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)