SOAP(suds-jurko):urllib.error.HTTPError:HTTP错误400:错误请求

时间:2016-05-12 13:48:38

标签: python soap suds

我正在尝试使用此网络服务:http://bsestarmfdemo.bseindia.com/MFOrderEntry/MFOrder.svc

这是我调用端点getPassword的python代码:

from suds.client import Client
import logging

logging.basicConfig(level=logging.DEBUG)
logging.getLogger('suds.client').setLevel(logging.DEBUG)

wsdl_url = 'http://bsestarmfdemo.bseindia.com/MFOrderEntry/MFOrder.svc?wsdl'

client = Client(wsdl_url, headers= { 'Content-Type' : 'application/soap+xml; charset=utf-8' } )

result = client.service.getPassword(UserId='XXXXXXX', Password='XXXXX', PassKey='passkey123')

这是一个错误,这是DEBUG输出:

DEBUG:suds.client:HTTP failed - 400 - Bad Request:
b'Bad Request'
ERROR:suds.client:<suds.sax.document.Document object at 0x1034ebc18>
Traceback (most recent call last):
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/transport/http.py", line 82, in send
    fp = self.u2open(u2request)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/transport/http.py", line 132, in u2open
    return url.open(u2request, timeout=tm)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py", line 469, in open
    response = meth(req, response)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py", line 579, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py", line 507, in error
    return self._call_chain(*args)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py", line 441, in _call_chain
    result = func(*args)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py", line 587, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/client.py", line 613, in send
    reply = self.options.transport.send(request)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/transport/https.py", line 66, in send
    return HttpTransport.send(self, request)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/transport/http.py", line 94, in send
    raise TransportError(e.msg, e.code, e.fp)
suds.transport.TransportError: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 14, in <module>
    result = client.service.getPassword(UserId='XXXXX', Password='XXXXX', PassKey='passkey123')
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/client.py", line 581, in invoke
    result = self.send(soapenv)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/client.py", line 619, in send
    description=tostr(e), original_soapenv=original_soapenv)
  File "/Users/mohit/anaconda3/envs/py34/lib/python3.4/site-packages/suds/client.py", line 677, in process_reply
    raise Exception((status, description))
Exception: (400, 'Bad Request')

我该如何解决这个问题?感谢任何线索,谢谢!

0 个答案:

没有答案