SOAP ( suds-jurko) : urllib.error.HTTPError: HTTP Error 400: Bad Request

自闭症网瘾萝莉.ら 提交于 2019-12-11 05:01:58

问题


I'm trying to use this web service : http://bsestarmfdemo.bseindia.com/MFOrderEntry/MFOrder.svc

This is my python code to call the endpoint getPassword :

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')

This is throwing an error, this is the DEBUG output :

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')

How do I fix this ? Any clue appreciated, thanks!

来源:https://stackoverflow.com/questions/37188918/soap-suds-jurko-urllib-error-httperror-http-error-400-bad-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!