开发者

python soappy add header

开发者 https://www.devze.com 2022-12-13 14:12 出处:网络
I have the following PHP example code: $client = new SoapClient("http://example.com/example.wsdl");

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

精彩评论

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

关注公众号