Search code examples
pythonweb-servicessoapwsdlsuds

TypeNotFound error in Suds Soap library


I'm trying to call a SOAP service from the Dutch land register (WSDL here) with the suds library. I first introspect the SOAPservice as follows:

>>> from suds.client import Client
>>> client = Client(url='http://www1.kadaster.nl/1/schemas/kik-inzage/20141101/verzoekTotInformatie-2.1.wsdl')
>>> print client

Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913

Service ( VerzoekTotInformatieService ) tns="http://www.kadaster.nl/schemas/kik-inzage/20141101"
   Prefixes (13)
      ns0 = "http://www.kadaster.nl/schemas/kik-inzage/20141101"
      ...
      ns9 = "http://www.kadaster.nl/schemas/kik-inzage/kadastraalberichtobject/v20141101"
   Ports (1):
      (VerzoekTotInformatieSOAP)
         Methods (1):
            VerzoekTotInformatie(ns3:Aanvraag Aanvraag, )  # <== WE WANT TO CALL THIS
         Types (278):
            ns10:AN1
            ns10:AN10
            ...
            ns3:Aanvraag  # <== FOR WHICH WE NEED THIS TYPE
            ns10:AlgemeenAfsluiting
            ns10:AlgemeenBegin
            ...

So I want to call the (only available) method VerzoekTotInformatie (which means "RequestForInformation") which takes an Aanvraag object ("Aanvraag" means "Request"). As you can see the Aanvraag type is in the list of Types. So I tried creating it as suggested in the docs, using:

>>> Aanvraag = client.factory.create('Aanvraag')
No handlers could be found for logger "suds.resolver"
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/suds/client.py", line 234, in create
    raise TypeNotFound(name)
TypeNotFound: Type not found: 'Aanvraag'
>>>

Does anybody know why the type is not found, even though it is clearly displayed in the list of types?

All tips are welcome!


Solution

  • You need to add the prefix:

    In [9]: Aanvraag = client.factory.create('ns3:Aanvraag')
    
    In [10]: Aanvraag
    Out[10]:
    (Aanvraag){
       berichtversie =
          (VersieAanvraagbericht){
             value = None
          }
       klantReferentie = None
       productAanduiding = None
       Gebruiker =
          (Gebruiker){
             identificatie = None
          }
       Ingang = <empty>
     }