Python 出现“运行时错误:调用 Python 对象时超出最大递归深度" [英] Python suds "RuntimeError: maximum recursion depth exceeded while calling a Python object"

查看:57
本文介绍了Python 出现“运行时错误:调用 Python 对象时超出最大递归深度"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Python suds 来使用 SOAP 网络服务,但出现错误RuntimeError:调用 Python 对象时超出了最大递归深度".

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".

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

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

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

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

我尝试访问的方法是 loadPathwayForId.

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)

我不确定是什么导致了无限递归.我试着查了一下这个问题,有报告说suds和无限递归有问题,但痕迹和我的不一样(递归代码不同),所以我怀疑我的问题有其他原因.

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.

完整的跟踪:

  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

预先感谢您的帮助!

推荐答案

我尝试了很多 SUDS 版本和分支,最终找到了一个适用于代理、https 和经过身份验证的服务,请在此处找到:

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

这篇关于Python 出现“运行时错误:调用 Python 对象时超出最大递归深度"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆