2009-08-29 11 views
9

Sto provando a utilizzare i servizi web di viaggio di SABER con Python Suds, ma un XSD sembra non ben formato (forse manca lo spazio dei nomi in questo schema).Come importare lo schema XSD con Python Suds (versione 0.3.6) Libreria SOAP: eccezione TypeNotFound?


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

traccia di debug rendimenti:


.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,)' 

E 'la logica: Python Suds carichi OTA_AirPriceRQ in uno spazio dei nomi "Nessuno". ho letto "risolvere schema rotto" documentazione 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) 

Ma script di tornare un'altra eccezione:


.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 

Non capisco come utilizzare le funzioni "Dottore". Qualcuno può aiutarmi, per favore? Grazie.

risposta

3

Ho appena postato una soluzione alternativa al biglietto Suds. Si consiglia di check it out: https://fedorahosted.org/suds/ticket/239#comment:19

In breve, ecco il codice di soluzione:

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