python的soappy增加头部

2024-09-30 02:26:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下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);

我的问题:soapyHeader()和\uu setSoapHeaders()部分的SOAPpy等价物是什么?在

相关问题


Tags: 代码comclienthttp示例newexamplearray
1条回答
网友
1楼 · 发布于 2024-09-30 02:26:44

下面是一个使用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)

相关问题 更多 >

    热门问题