PythonでSOAPリクエストを送信するときにヘッダを追加しようとしました。私が使用している要求にヘッダを追加するPythonのSOAPメッセージ
> <SOAP-ENV:Header>
> <ns3:userCredentials
> xsi:type="https://4psa.com/HeaderData.xsd/2.0.0">
> <username>admin</username>
> <password>welcome</password>
> </ns3:userCredentials>
> </SOAP-ENV:Header>
:
from suds.client import Client
from suds.xsd.doctor import ImportDoctor, Import
wsdl = 'https://192.168.1.15//soap2/schema/2.5.0/Report/Report.wsdl'
client = Client(wsdl)
と私は、このコードにヘッダを追加する方法を知っている `tをSOAPで
ヘッダがあります。
追加方法をご提案ください。
そして、私が試した:
> >>> from suds.client import Client
> >>> from suds.xsd.doctor import ImportDoctor, Import
> >>> imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
> >>> url = 'https://192.168.1.15//soap2/schema/2.5.0/Report/Report.wsdl'
> >>> client = Client(url)
> >>> userid = 'admin'
> >>> passwd = '[email protected]'
> >>> client.set_options(soapheaders=(userid,passwd))
> >>> print client a get error when run:
>
> >>> client.service.CallCosts(1) Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File
> "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/client.py",
> line 542, in __call__
> return client.invoke(args, kwargs) File
> "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/client.py",
> line 602, in invoke
> result = self.send(soapenv) File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/client.py",
> line 637, in send
> reply = transport.send(request) File
> "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/transport/https.py",
> line 64, in send
> return HttpTransport.send(self, request) File
> "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/transport/http.py", line 77, in send
> fp = self.u2open(u2request) File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/transport/http.py", line 118, in u2open
> return url.open(u2request, timeout=tm) File
> "/usr/lib/python2.6/urllib2.py", line
> 391, in open
> response = self._open(req, data) File "/usr/lib/python2.6/urllib2.py",
> line 409, in _open
> '_open', req) File "/usr/lib/python2.6/urllib2.py", line
> 369, in _call_chain
> result = func(*args) File "/usr/lib/python2.6/urllib2.py", line
> 1169, in https_open
> return self.do_open(httplib.HTTPSConnection,
> req) File
> "/usr/lib/python2.6/urllib2.py", line
> 1136, in do_open
> raise URLError(err) urllib2.URLError: <urlopen error
> [Errno 111] Connection refused>
をあなたはここでの問題が何であるかを知っていればお勧めしてください。
のような何かをしました。 – codeScriber