Python suds“运行时错误:调用Python对象时超过最大递归深度”

2024-04-19 08:21:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用pythonsuds来使用soapweb服务,但是我得到了一个错误“RuntimeError:maximum recursion depth exceeded when calling a Python object”。在

根据跟踪,在“suds/binding”处有无限递归/多参考py“,第69行。在

我试图访问的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)

我不确定是什么导致了无限递归。我试着查找这个问题,有报道说sud和无限递归有问题,但这些痕迹与我的不同(递归代码不同),所以我怀疑我的问题有其他根源。在

完整轨迹:

^{pr2}$

提前感谢您的帮助!在


Tags: 代码orgclientwebhttpwwwservicesuds
2条回答

我尝试了很多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

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

相关问题 更多 >