1

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 question

Community
  • 1
  • 1
dandu
  • 800
  • 1
  • 8
  • 18

1 Answers1

1

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)
jfs
  • 399,953
  • 195
  • 994
  • 1,670