2

我正在尝试使用 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

在此先感谢您的帮助!

4

2 回答 2

0

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.

于 2013-09-03T20:13:42.060 回答
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
于 2014-07-23T11:00:28.150 回答