我尝试连接http://data.opensolution.se/index.php?wsdl并使用以下代码:
from suds.client import Client
from suds.xsd.doctor import ImportDoctor, Import
url = 'http://data.opensolution.se/index.php?wsdl'
imp = Import('http://www.w3.org/2001/XMLSchema',
location='http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://data.opensolution.se/')
client = Client(url, doctor=ImportDoctor(imp))
但它会引发错误:
suds.TypeNotFound TypeNotFound:未找到类型:'(xml,http://www.w3.org/2001/XMLSchema,)'
我也试过玩我在imp.filter.add中添加的内容,例如:
imp.filter.add('http://data.opensolution.se/soap/OSDataService')
我从5年前的帖子中了解了以下信息,开始使用ImportDoctor:SOAP suds and the dreaded schema Type Not Found error
找到的代码有效:
from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor
url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl'
imp = Import('http://www.w3.org/2001/XMLSchema',
location='http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://WebXml.com.cn/')
client = Client(url, doctor=ImportDoctor(imp))
正如你所看到的,这几乎就是我的起点,但它并不适合我。
提前感谢任何提示。
答案 0 :(得分:0)
以下内容将消除您的Type not found
错误:
from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor
url = 'http://data.opensolution.se/index.php?wsdl'
imp = Import('http://www.w3.org/2001/XMLSchema')
doctor = ImportDoctor(imp)
client = Client(url, doctor=doctor)
但你可能会遇到这个错误:SOAPpy
导致:
File "/usr/local/.virtualenvs/stackoverflow/lib/python2.7/site-packages/suds/xsd/sxbasic.py", line 756, in create
return fn(schema, root)
File "/usr/local/.virtualenvs/stackoverflow/lib/python2.7/site-packages/suds/xsd/sxbasic.py", line 376, in __init__
TypedContent.__init__(self, schema, root)
File "/usr/local/.virtualenvs/stackoverflow/lib/python2.7/site-packages/suds/xsd/sxbase.py", line 95, in __init__
self.name = root.get('name')
File "/usr/local/.virtualenvs/stackoverflow/lib/python2.7/site-packages/suds/sax/element.py", line 234, in get
attr = self.getAttribute(name, ns)
File "/usr/local/.virtualenvs/stackoverflow/lib/python2.7/site-packages/suds/sax/element.py", line 404, in getAttribute
prefix, name = splitPrefix(name)
File "/usr/local/.virtualenvs/stackoverflow/lib/python2.7/site-packages/suds/sax/__init__.py", line 49, in splitPrefix
if isinstance(name, basestring) \
RuntimeError: maximum recursion depth exceeded while calling a Python object
所以,也许尝试另一个肥皂客户端,如http://www.diveintopython.net/soap_web_services/introspection.html
使用pip安装它:
pip install soappy
以下示例改编自本教程:This
>>> from SOAPpy import WSDL
>>> wsdlFile = 'http://data.opensolution.se/index.php?wsdl'
>>> server = WSDL.Proxy(wsdlFile)
>>> server.methods.keys()
[u'GetFlightPrepackById', u'GetMdbArticles', u'CardPurchase', u'GetNewArticleNumber', u'GetAccountingAccounts', u'ExportZ', u'AddBookingQuote', u'DeleteTableBooking', u'GetTravelDepartures', u'SaveCashRegister', u'DecreaseTravelBooking', u'GetEventLog', u'GetCustomersByCategory', u'DeleteCustomer', u'SaveCurrencies', u'GetReportArticleRating', u'GetXReport', u'GetEmployeeBySearch', u'SaveMdbCategories', u'LetoUnlockOrder', u'GetFlightPrepackArticlesByPrepackId', u'GetTableByNo', u'GetOrdersByFlightId', u'RemoveFlightPrepackById', u'GetCustomers', u'GetReports', u'GetCityBreakBooking', u'GetArticleOption', u'AddBookingQuoteArticle', u'GetGiftCardOrdersByOrderId', u'SaveVatAccount', u'GetOrder', u'GetEmployeeCategories', u'GetBooking', u'GetCashRegisterCategoryById', u'AddLoyaltyRecord', u'SaveArticle', u'GetDibsTokens', u'GetCode', u'AddFlightStaffByFlightId', u'GetEventLogCategories', u'SavePaymentAccount', u'GetEmployeeCategoryById', u'RemoveFlightStaffByFlightId', u'GetOrders', u'ResetSamportOrder', u'GetStartPage', u'SaveCurrency', u'GetZArticleReport', u'GetFlightRoutes', u'GetFlightNumberByNumber', u'GetOrdersByDate', u'GetCardTypeByName', u'GetRebateCategories', u'SaveInvoice', u'GetArticles', u'GetTablesByStatus', u'GetCardReportByDate', u'NewCard', u'GetFlightNumberById', u'GetEmployees', u'GetArticleById', u'GetTableCategoryById', u'GetBookingByDate', u'GetCardGroups', u'SaveCardReportTransaction', u'GetArticlesBySearch', u'RegisterBackup', u'GetFlightByZ', u'GetCardTransactions', u'GetOrdersFromInvoice', u'ExportEmployees', u'LetoDeleteOrder', u'CardFill', u'UpdateCard', u'GetEmployeeByWaiterId', u'SaveEmployeeCategory', u'GetTableById', u'SaveAccount', u'DeleteFlightPrepackArticleByPrepackId', u'SaveCustomer', u'GetFlightsByDate', u'SaveStartPageButton', u'GetCardReportBatch', u'GetActiveCodes', u'GetAccountingCategories', u'CCUGetControlCode', u'GetCustomerCategoryById', u'GetSales', u'GetFlightCommission', u'GetEvents', u'ChangeCitybreakBooking', u'AddSamportOrder', u'GetTravelOrders', u'GetCustomerCategories', u'DeleteStartPage', u'LetoGetOpenOrders', u'GetCards', u'GetAccountingPaymentMethods', u'GetGiftCardByMagCardNo', u'GetGiftCardOrdersByGiftCardId', u'CCUGetSerialNumber', u'GetAccountDistributionByReportId', u'GetReportsByDate', u'GetGrandArticleReport', u'GetNewEmployeeNumber', u'GetFlightPrepacksByDelivered', u'LetoAddOrder', u'SaveAccountingVatAccount', u'GetFlightById', u'GetCard', u'GetFlightStaffByFlightId', u'GetCustomerById', u'GetReportByDateAndFlightNr', u'DeleteCurrency', u'GetGiftCardById', u'GetTravelPrice', u'SaveDibsToken', u'GetEventLogTypes', u'GetArticleImage', u'LetoChangeOrder', u'GetFlightPrepacksByFlightId', u'GetXArticleReport', u'LetoGetOrderInfo', u'GetTravelRoutes', u'GetTableOrder', u'AddFlightPrepackArticleByPrepackId', u'GetOrdersByTime', u'GetArticleOptions', u'SaveActiveCode', u'GetFlightPrepacksBySearch', u'GetAccountingAccount', u'SaveCardReportBatch', u'GetRebateCategoriesMap', u'GetGiftCardOrdersByDate', u'GetPlaces', u'GetCustomerBySearch', u'GetLoyaltyRecords', u'GetCardsByCardGroup', u'GetFlightNumbers', u'GetReportsByFlightId', u'GetInvoices', u'DeleteCitybreakBooking', u'ExportArticles', u'GetArticleCategories', u'DeleteSamportOrder', u'GetArticleTypes', u'GetInvoiceById', u'GetAccountingVat', u'GetTravelPrices', u'GetReportById', u'GetMdbCategoriesArticles', u'GetCompanies', u'GetReportByDate', u'GetCompanyById', u'GetCashRegistersByCategory', u'GetCardReportLatest', u'SaveFlightNumber', u'SaveCompany', u'SaveCustomerCategory', u'GetReportHeadersByFlightId', u'GetCashRegistersBySearch', u'ExportOrders', u'GenerateReport', u'GetTravelOrder', u'GetGiftCardsByCustomerId', u'LetoPayByCash', u'SaveMdbArticles', u'GetMdbCategories', u'ExportInvoices', u'SaveArticleOption', u'GetCodes', u'GetOrdersByFilter', u'GetRebateGroups', u'GetGiftCards', u'CreateCitybreakBooking', u'ExportOrdersWithArticles', u'SaveCashRegisterCategory', u'CardCancel', u'GetArticleCategoryById', u'DeleteAccountingAccount', u'GetCodeCategories', u'GetArticlesByCategory', u'GetTravelStops', u'GetCashRegisterById', u'GetTableStatus', u'GetCardGroup', u'CardRefund', u'IncreaseTravelBooking', u'ExportCustomers', u'GetFlightPrepacksByStatus', u'GetFlightsByFlightNr', u'GetAccounts', u'SaveAccountingAccount', u'GetInvoiceByOrderId', u'GetDatabaseName', u'GetTablesByCategoryId', u'GetStartPages', u'GetTableCategories', u'SaveStartPage', u'SaveAccountingPaymentMethodAccount', u'UpdateFlightPrepackArticleByPrepackId', u'GetCashRegisterCategories', u'GetActiveCode', u'SaveTableBooking', u'LetoAbortOrder', u'GetCurrencies', u'GetCashRegisters', u'GetReportsByLimit', u'GetFlightTerminals', u'SaveArticleCategory', u'GetCardTypeById', u'GetTravelOrdersByDeparture', u'SaveEmployee', u'GetRebateCategory', u'GetOrdersByReportId', u'DeleteStartPageButton', u'GetCardByCardNo', u'GetEmployeesByCategory', u'GetEmployeeById', u'DeleteActiveCode', u'GetTables']
>>> callInfo = server.methods['GetTables']
>>> callInfo.inparams
[<wstools.WSDLTools.ParameterInfo instance at 0x2aeaa2823bd8>]
>>> callInfo.inparams[0].name
u'ApiKey'
>>> callInfo.inparams[0].type
(u'http://www.w3.org/2001/XMLSchema', u'string')
>>> callInfo.outparams
[<wstools.WSDLTools.ParameterInfo instance at 0x2aeaa2823c20>]
>>> callInfo.outparams[0].name
u'return'
>>> callInfo.outparams[0].type
(u'http://www.w3.org/2001/XMLSchema', u'string')
答案 1 :(得分:0)
我遇到了同样的问题,最终通过将我使用的suds-py3 1.4.1.0客户端更改为suds-jurko == 0.6
来解决了该问题。