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

Python SOAP(suds-jurko):urllib.error.HTTPError:HTTP错误400:错误请求,python,soap,suds,Python,Soap,Suds,我正在尝试使用此web服务: 这是我调用端点的python代码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/M

我正在尝试使用此web服务:

这是我调用端点的python代码
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')
这会引发错误,这是调试输出:

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')
DEBUG:suds.client:HTTP失败-400-错误请求:
b‘坏请求’
错误:suds.client:
回溯(最近一次呼叫最后一次):
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/transport/http.py”,第82行,在send中
fp=self.u2open(u2request)
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/transport/http.py”,第132行,打开
返回url.open(u2request,timeout=tm)
打开文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py”,第469行
响应=方法(请求,响应)
http_响应中的文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py”,第579行
“http”、请求、响应、代码、消息、hdrs)
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py”,第507行出错
返回自我。调用链(*args)
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py”,第441行,在调用链中
结果=func(*args)
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/urllib/request.py”,第587行,默认为http\u error\u
raise HTTPError(请求完整的url、代码、消息、hdrs、fp)
urllib.error.HTTPError:HTTP错误400:请求错误
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/client.py”,第613行,在send中
reply=self.options.transport.send(请求)
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/transport/https.py”,第66行,在send中
返回HttpTransport.send(self,request)
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/transport/http.py”,第94行,在send中
raise TRANSPORT错误(e.msg、e.code、e.fp)
suds.transport.TransportError:请求错误
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“test.py”,第14行,在
结果=client.service.getPassword(UserId='XXXXX',Password='XXXXX',PassKey='passkey123')
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/client.py”,第521行,在调用中__
返回client.invoke(args、kwargs)
调用中的文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/client.py”,第581行
结果=self.send(soapenv)
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/client.py”,第619行,在send中
description=tostr(e),original_soapenv=original_soapenv)
文件“/Users/mohit/anaconda3/envs/py34/lib/python3.4/site packages/suds/client.py”,第677行,正在处理中
引发异常((状态、说明))
异常:(400,“错误请求”)

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

你得到了堆栈跟踪,还是什么都没有?我建议您在cURL中模拟相同的请求,并通过Fiddler将其传递给它,这样您就可以看到如果它工作,请求之间的差异。什么都没有。函数调用只会在cli上产生上述跟踪。请尝试在cURL中执行相同的请求。。。您还可以使用proxy属性将您的请求通过管道传输到Fiddlr中,以查看标头并比较cURL和suds是否得到堆栈跟踪,还是什么都没有?我建议您在cURL中模拟相同的请求,并通过Fiddler将其传递给它,这样您就可以看到如果它工作,请求之间的差异。什么都没有。函数调用只会在cli上产生上述跟踪。请尝试在cURL中执行相同的请求。。。您还可以使用proxy属性将请求通过管道传输到Fiddlr中,以查看标题并比较cURL和sud