Search code examples
pythonsoapwsdlclientsuds

suds throwing error 'type not found' consuming SOAP service


I am consuming a SOAP webservice with suds (0.4). The WSDL I am using throws an error

>>> import uuid
>>> from suds.client import Client
>>> wsdl = 'https://toolkit.dnb.com/locked/resource/docs/TransactionAndMessageDefinition/ProductList.wsdl'
>>> client = Client(wsdl) 

The service I am consuming expects one parameter productListRequest, which is a complex type where you put UserId, Password and a complex type of ProductListInput.

I fill these with:

>>> productListRequest = client.factory.create('productListRequest')
>>> productListRequest.UserId = 'myusername'
>>> productListRequest.Password = 'mypassword'
>>> productListRequest.TRNUID = uuid.uuid4()
>>> ProductListInput = client.factory.create('ProductListInput')
>>> ProductListInput.DnB_DUNS_Number = ''
>>> ProductListInput.Product = 'Product Name'
>>> ProductListInput.CountryCode = 'IT'
>>> ProductListInput.TradeUp = ''
>>> ProductListInput.Reason = ''
>>> productListRequest.ProductListInput = ProductListInput

But whenever I am calling the service:

>>> print client.service.ws_ProductList(productListRequest)

I get Type not found: 'ArrayOfUPD_FLDSItem'

I am really stuck here. I have googled this error for 2 days and honestly I do not know what to do! Maybe someone with a deeper understanding of WSDL and suds can help.

So my questions:

  • Is this WSDL, which I am consuming proper defined? (If it is proper defined, I will report it to the suds maintainers)

  • If this WSDL is not proper defined, is there a workaround (e.g. suds schema doctor) to fix it on suds site?

  • Is there a alternative Python library, which I should use?


Solution

  • Suds is currently the best choice for WSDL consumption in Python. Unfortunately WSDL itself is such a complex mess that making good out of it is difficult.

    Luckily Suds come with extensive logging capabilities which you can use to debug the problem and this is the first step of solving it. This earlier question answers how to enable it:

    How can I output what SUDs is generating/receiving?

    However, giving a complete answer for the type error would require seeing extensive logging output and/or source code, so I suggest you somehow try to narrow down the problem. To make the problem ultimately solvable a sample (non-working) schema and Python code would be nice.

    (The error might hint that there is some subschema / external schema defined / missing which Suds cannot load for reason X)