SUDS PYTHON SOAP请求Maxbounty

时间:2018-08-21 19:20:50

标签: python soap suds zeep

我正在尝试使用以下代码从MaxBounty的服务器获取“ helloWorld”响应:

from suds.client import Client
from suds.plugin import MessagePlugin
import logging

logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)

class NS0Converter(MessagePlugin):
    def marshalled(self, context):
        body = context.envelope.getChild("Body")
        body.setPrefix("SOAP-ENV")
        soap_env_parent = context.envelope
        del soap_env_parent.nsprefixes['ns0']
        del soap_env_parent.nsprefixes['ns1']
        del soap_env_parent.nsprefixes['xsi']
        soap_env_parent.set('xmlns:ns1', 'http://ws.apache.org/axis2')
        child = body.getChild("helloWorld")
        child.setPrefix("ns1")

client = Client('http://www.maxbounty.com/api.cfc?wsdl', headers={'SOAPAction':'urn:helloWorld', 'Connection':'Keep-Alive', 'Content-Type':'text/xml; charset=utf-8'}, plugins=[NS0Converter()])

res = client.service.helloWorld()

不幸的是,我从Python请求中收到错误500-服务器错误。我已经以PHP形式复制了此代码,它可用于以下请求:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.apache.org/axis2">
     <SOAP-ENV:Body>
          <ns1:helloWorld/>
     </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

但是在SUDS中使用以下请求:

b'<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.apache.org/axis2">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
        <ns1:helloWorld/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>'

我要去哪里错了?我从肥皂泡中得到的错误消息在这里:

ERROR:suds.client:<suds.sax.document.Document object at 0x000001F1CD095400>
Traceback (most recent call last):
  File "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\transport\http.py", line 82, in send
  File "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\transport\http.py", line 132, in u2open
  File "D:\Python\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "D:\Python\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "D:\Python\lib\urllib\request.py", line 563, in error
    result = self._call_chain(*args)
  File "D:\Python\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "D:\Python\lib\urllib\request.py", line 755, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "D:\Python\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "D:\Python\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "D:\Python\lib\urllib\request.py", line 563, in error
    result = self._call_chain(*args)
  File "D:\Python\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "D:\Python\lib\urllib\request.py", line 755, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "D:\Python\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "D:\Python\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "D:\Python\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "D:\Python\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "D:\Python\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 "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\client.py", line 613, in send
  File "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\transport\https.py", line 66, in send
  File "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\transport\http.py", line 94, in send
suds.transport.TransportError: Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Tom Work\MaxBounty\MaxBounty\maxBountySUDS.py", line 44, in <module>
    res = client.service.helloWorld()
  File "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\client.py", line 521, in __call__
  File "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\client.py", line 581, in invoke
  File "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\client.py", line 619, in send
  File "D:\Python\lib\site-packages\suds_jurko-0.6-py3.7.egg\suds\client.py", line 677, in process_reply
Exception: (500, 'Internal Server Error')

0 个答案:

没有答案