Python suds “RuntimeError: maximum recursion depth exceeded while calling a Python object”

て烟熏妆下的殇ゞ 提交于 2019-11-27 08:34:11

问题


I'm trying to consume a SOAP web service using Python suds but I am getting the error "RuntimeError: maximum recursion depth exceeded while calling a Python object".

According to the trace, there is infinite recursion at "suds/binding/multiref.py", line 69.

The web service I'm trying to access is http://www.reactome.org:8080/caBIOWebApp/services/caBIOService?wsdl.

The method I'm trying to access is loadPathwayForId.

Here's the part of my code that consumes the web service:

from suds.client import Client
client = Client('http://www.reactome.org:8080/caBIOWebApp/services/caBIOService?wsdl')
pathway = client.service.loadPathwayForId(2470946)

I'm not sure what is responsible for the infinite recursion. I tried to look up this problem and there has been reports of issues with suds and infinite recursion, but the traces are different than mine (the recursive code is different), so I suspect my problem has other origins.

The full trace:

  File "C:\Python27\lib\suds\bindings\multiref.py", line 69, in update
      self.update(c)
  File "C:\Python27\lib\suds\bindings\multiref.py", line 69, in update
      self.update(c)
  ...
  File "C:\Python27\lib\suds\bindings\multiref.py", line 69, in update
      self.update(c)
  File "C:\Python27\lib\suds\bindings\multiref.py", line 69, in update
      self.update(c)
  File "C:\Python27\lib\suds\bindings\multiref.py", line 67, in update 
      self.replace_references(node)
  File "C:\Python27\lib\suds\bindings\multiref.py", line 80, in replace_references
      href = node.getAttribute('href')
  File "C:\Python27\lib\suds\sax\element.py", line 404, in getAttribute
      prefix, name = splitPrefix(name)
  File "C:\Python27\lib\suds\sax\__init__.py", line 49, in splitPrefix
    if isinstance(name, basestring) \
RuntimeError: maximum recursion depth exceeded while calling a Python object

Thanks in advance for the help!


回答1:


After more testing, it seems that (unfortunately) suds has trouble interpreting Java Collection objects serialized as XML. I ended up using SOAPpy instead to avoid this issue. If someone can suggest a fix, that would be awesome! I really like suds for its other merits over SOAPpy.




回答2:


I tried lots of SUDS versions and forks, and finally got to find one that works with proxies, https and authenticated services, find it here:

https://github.com/unomena/suds

Also, here is example code showing simple usage:

from suds.client import Client

# SOAP WSDL url
url = 'https://example.com/ws/service?WSDL'

# SOAP service username and password for authentication, if needed
username = 'user_name'
password = 'pass_word'

# local intranet proxy definition to get to the internet, if needed
proxy = dict(http='http://username:password@localproxy:8080',
             https='http://username:password@localproxy:8080')

# unauthenticaded, no-proxy
# client = Client(url)

# use a proxy to connect to the service
# client = Client(url, proxy=proxy)

# no proxy, authenticathed service
# client = Client(url, username=username, password=password)

# use a proxy to connect to an authenticated service
client = Client(url, proxy=proxy, username=username, password=password)

print client


来源:https://stackoverflow.com/questions/18455945/python-suds-runtimeerror-maximum-recursion-depth-exceeded-while-calling-a-pyth

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