Search code examples
pythonsoapsuds

suds.TypeNotFound error


I'm trying to connect to http://data.opensolution.se/index.php?wsdl and used the following code:

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))

but it throws the error:

suds.TypeNotFound TypeNotFound: Type not found: '(xml, http://www.w3.org/2001/XMLSchema, )'

I also tried playing around with what I add in imp.filter.add, e.g.:

imp.filter.add('http://data.opensolution.se/soap/OSDataService')

I started using the ImportDoctor by following info from a post from 5 years ago: SOAP suds and the dreaded schema Type Not Found error

The code found there works:

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))

As you can see, this is pretty much what I started from, but it doesn't work for me.

Thanks in advance for any tips.


Solution

  • The following will get rid of your Type not found error:

    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)
    

    But you'll likely run into this bug: https://fedorahosted.org/suds/ticket/239

    Resulting in:

      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
    

    So, perhaps try another soap client like SOAPpy

    Install it with pip:

    pip install soappy
    

    Examples below adapted from this tutorial: http://www.diveintopython.net/soap_web_services/introspection.html

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