How to construct SOAP message with pysimplesoap?

后端 未结 1 762
傲寒
傲寒 2021-02-06 19:12

I\'m trying to call a SOAP service from the Dutch government land register (WSDL here) with PySimpleSoap. So far I did this to connect:

from pysimplesoap.client          


        
1条回答
  •  孤独总比滥情好
    2021-02-06 19:50

    Constructing xml is not the necessary (or correct) way to call a soap method. PySimpleSoap has already provided quite an elegant and human-readable way to do this:

    client = SoapClient(wsdl='http://www1.kadaster.nl/1/schemas/kik-inzage/20141101/verzoekTotInformatie-2.1.wsdl', trace=True)
    client.VerzoekTotInformatie(Aanvraag={'berichtversie':4.7, 
                                          'klantReferentie':'cum murmure', 
                                          'productAanduiding': 'aeoliam venit'})
    

    The debug log would be like this:

    INFO:pysimplesoap.client:POST https://service1.kadaster.nl/kik/inzage/20141101/VerzoekTotInformatieService
    DEBUG:pysimplesoap.client:SOAPAction: "VerzoekTotInformatie"
    Content-length: 842
    Content-type: text/xml; charset="UTF-8"
    DEBUG:pysimplesoap.client:
    
        
            
                
                    
                        4.7000000000
                        cum murmure
                        aeoliam venit
                    
                
            
    
    

    As you can see, the xml is automatically constructed and sent to server. However I got 401: Unauthorized error, which you may know how to fix.

    0 讨论(0)
提交回复
热议问题