如何将dict标头中的dict传递给suds客户端进行bmc补救wsdl调用?

时间:2019-06-16 11:51:37

标签: python python-3.x wsdl suds remedy

尽管传递了凭据,但是SOAP调用并未通过python中的Suds进行身份验证。

我无法直接传递用户名和密码,因为我的Web服务需要用户名和密码作为参数值。

from suds.client import Client
c = Client('http://<<server.domain:port>>/arsys/WSDL/public/<<server>>/<<webservice>>')
request_data = {
            "Qualification":
                "'Modified Date' >=\"{0}\" and "
                "'Categorization Tier 2' = \"{1}\" and "
                "'Submitter' = \"{2}\"".format('12/17/2018', '<<tier>>', '<<submitter>>')
        }
soap_headers = \
    {
        'parameters': {
            'userName': '<<username>>',
            'password': '<<password>>'
        }
    }
c.set_options(soapheaders=soap_headers)
c.service.<<soapcallormethodname>>(**request_data)

预期结果: 该方法应成功执行并返回补救票证列表。

实际结果:

<suds.sax.document.Document object at 0x06195D90>
Traceback (most recent call last):
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\transport\http.py", line 82, in send
    fp = self.u2open(u2request)
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\transport\http.py", line 132, in u2open
    return url.open(u2request, timeout=tm)
  File "C:\Program Files (x86)\Python37-32\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Program Files (x86)\Python37-32\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Program Files (x86)\Python37-32\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Program Files (x86)\Python37-32\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Program Files (x86)\Python37-32\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\client.py", line 613, in send
    reply = self.options.transport.send(request)
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\transport\https.py", line 66, in send
    return HttpTransport.send(self, request)
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\transport\http.py", line 94, in send
    raise TransportError(e.msg, e.code, e.fp)
suds.transport.TransportError: Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/projects/xxxxx/sudsss.py", line 17, in <module>
    c.service.New_GetList_Operation_0(**request_data)
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\client.py", line 581, in invoke
    result = self.send(soapenv)
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\client.py", line 619, in send
    description=tostr(e), original_soapenv=original_soapenv)
  File "C:\Users\xx\AppData\Roaming\Python\Python37\site-packages\suds\client.py", line 670, in process_reply
    raise WebFault(fault, replyroot)
suds.WebFault: Server raised fault: 'ARERR [149] A user name must be supplied in the control record'

注意:我不能使用zeep,因为python 3.4.3(我要严格编码的地方)不支持zeep的依赖关系

0 个答案:

没有答案