蟒蛇泡沫"RuntimeError: maximum recursion depth exceeded while calling a Python object"



我试图使用Python脚本使用SOAP web服务,但收到错误"RuntimeError:调用Python对象时超过了最大递归深度"。

根据跟踪,在第69行的"suds/binding/multuref.py"处存在无限递归。

我尝试访问的web服务是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:Python27libsudsbindingsmultiref.py", line 69, in update
      self.update(c)
  File "C:Python27libsudsbindingsmultiref.py", line 69, in update
      self.update(c)
  ...
  File "C:Python27libsudsbindingsmultiref.py", line 69, in update
      self.update(c)
  File "C:Python27libsudsbindingsmultiref.py", line 69, in update
      self.update(c)
  File "C:Python27libsudsbindingsmultiref.py", line 67, in update 
      self.replace_references(node)
  File "C:Python27libsudsbindingsmultiref.py", line 80, in replace_references
      href = node.getAttribute('href')
  File "C:Python27libsudssaxelement.py", line 404, in getAttribute
      prefix, name = splitPrefix(name)
  File "C:Python27libsudssax__init__.py", line 49, in splitPrefix
    if isinstance(name, basestring) 
RuntimeError: maximum recursion depth exceeded while calling a Python object

提前感谢您的帮助!

经过更多的测试,(不幸的是)suds似乎在解释序列化为XML的Java Collection对象时遇到了问题。为了避免这个问题,我最终使用了SOAPpy。如果有人能提出一个解决方案,那就太棒了!我真的很喜欢suds,因为它比SOAPpy有其他优点。

我尝试了很多SUDS版本和fork,最终找到了一个可以使用代理、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

相关内容

最新更新