Python suds“RuntimeError:调用Python对象时超出了最大递归深度”

时间:2013-08-27 02:20:39

标签: python web-services soap recursion suds

我正在尝试使用Python suds来使用SOAP Web服务但是我收到错误“RuntimeError:调用Python对象时超出了最大递归深度”。

根据跟踪,在“suds / binding / multiref.py”第69行有无限递归。

我正在尝试访问的网络服务是http://www.reactome.org:8080/caBIOWebApp/services/caBIOService?wsdl

我尝试访问的方法是loadPathwayForId。

以下是我的代码中使用Web服务的部分:

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

我不确定无限递归的原因是什么。我试图查找这个问题,并且已经有关于suds和无限递归问题的报告,但是跟踪不同于我的(递归代码是不同的),所以我怀疑我的问题有其他来源。

完整的痕迹:

  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

提前感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

经过更多测试后,似乎(不幸的是)suds在解释序列化为XML的Java Collection对象时遇到了麻烦。我最终使用SOAPpy来避免这个问题。如果有人可以建议修复,那就太棒了!我非常喜欢肥皂泡沫,因为它在SOAPpy上有其他优点。

答案 1 :(得分:0)

我尝试了很多SUDS版本和分支,最后找到了一个与代理,https和经过身份验证的服务一起使用的版本,在这里找到它:

https://github.com/unomena/suds

此外,以下是显示简单用法的示例代码:

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