python - 如何使用 Python Suds(版本 0.3.6)SOAP 库 : TypeNotFound exception? 导入 XSD 模式

标签 python soap wsdl suds

我正在尝试将 SABRE 旅行 Web 服务与 Python Suds 结合使用,但是一个 XSD 似乎格式不正确(可能在此架构中缺少命名空间)。


from suds.client import Client
wsdl = 'http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl'
client = Client(wsdl, cache=None)

调试跟踪返回:


.DEBUG:suds.wsdl:reading wsdl at: http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl ...
DEBUG:suds.transport.http:opening (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl)
DEBUG:suds.metrics:sax (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl) duration: 406 (ms)
DEBUG:suds.xsd.sxbasic:Import:0x7f90196fd5f0, importing ns="http://webservices.sabre.com/sabreXML/2003/07", location="OTA_AirPriceLLSRQRS.xsd"
DEBUG:suds.transport.http:opening (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQRS.xsd)
DEBUG:suds.metrics:sax (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQRS.xsd) duration: 504 (ms)
DEBUG:suds.xsd.sxbasic:Include:0x7f90196fdf80, importing ns="None", location="OTA_AirPriceLLSRQ.xsd"
DEBUG:suds.transport.http:opening (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.xsd)
DEBUG:suds.metrics:sax (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.xsd) duration: 1.363 (seconds)
DEBUG:suds.xsd.schema:built:
Schema:0x7f9019708e60
(...)
DEBUG:suds.xsd.query:(u'MessageHeader', http://www.ebxml.org/namespaces/messageHeader), found as: 
DEBUG:suds.xsd.query:(u'Security', http://schemas.xmlsoap.org/ws/2002/12/secext), found as: 
DEBUG:suds.xsd.query:(u'OTA_AirPriceRQ', http://webservices.sabre.com/sabreXML/2003/07), not-found
.
----------------------------------------------------------------------
Ran 2 tests in 11.669s

Type not found: '(OTA_AirPriceRQ, http://webservices.sabre.com/sabreXML/2003/07, )'

这是逻辑:Python Suds 在“None”命名空间中加载 OTA_AirPriceRQ。 我阅读了“修复损坏的模式”Python Suds 文档(https://fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAs):


from suds.client import Client
from suds.xsd.doctor import ImportDoctor, Import
wsdl = 'http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl'
imp = Import('http://webservices.sabre.com/sabreXML/2003/07/OTA_AirPriceLLSRQ', 'http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.xsd')
d = ImportDoctor(imp)
client = Client(wsdl, cache=None, doctor=d)

但是脚本返回另一个异常:


.DEBUG:suds.wsdl:reading wsdl at: http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl ...
DEBUG:suds.transport.http:opening (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl)
DEBUG:suds.metrics:sax (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl) duration: 617 (ms)
DEBUG:suds.xsd.doctor:inserting: 
DEBUG:suds.xsd.sxbasic:Import:0xe6cf80, importing ns="http://webservices.sabre.com/sabreXML/2003/07/OTA_AirPriceLLSRQ", location="http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.xsd"
DEBUG:suds.transport.http:opening (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.xsd)
DEBUG:suds.metrics:sax (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.xsd) duration: 1.375 (seconds)
DEBUG:suds.xsd.doctor:inserting: 
(...)
Error maximum recursion depth exceeded while calling a Python object

我不明白如何使用“医生”功能。有人可以帮助我吗? 谢谢。

最佳答案

我刚刚发布了该 Suds 票证的解决方法。您可能想检查一下:https://fedorahosted.org/suds/ticket/239#comment:19

简单地说,这里是解决方法代码:

from suds.client import Client
import sys
sys.setrecursionlimit(10000)
c = Client('http://url.to/endpoint?wsdl', cache=None)

关于python - 如何使用 Python Suds(版本 0.3.6)SOAP 库 : TypeNotFound exception? 导入 XSD 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1351125/

相关文章:

python - 如何删除Python中关键字第一次出现之前的字符串?

java - 我如何测试我的连接池是否以正确的方式工作?

perl - 如何使用 Perl SOAP::Lite 将文件从本地计算机上传到 Sharepoint?

java - 如何从 Java 中的 SOAP 响应中提取数据?

.net - XSD 第一个合约 - WCF Soap Web 服务

java - WSDL 更改后 Apache Axis 失败

python - 是否可以用 python 编写防火墙?

python - 为什么舱口不显示?

c# - 如何将 .discomap 文件导入到我在 Visual Studio 2012 中的项目中?

Python 3.2 : How do you install easy_install