suds-community / suds

Suds is a lightweight SOAP python client for consuming Web Services. A community fork of the jurko fork.
https://suds.readthedocs.io/
GNU Lesser General Public License v3.0
173 stars 56 forks source link

How to create SOAP 1.2 requests? #101

Open t-arn opened 5 months ago

t-arn commented 5 months ago

I have a webservice which uses SOAP 1.2, but suds always creates a SOAP 1.1 message:

Can I configure suds to create a SOAP 1.2 compliant message or is this feature missing?

The WSDL is here: https://[wsg.isceco.admin.ch/Livestock/AnimalTracingWSDL/3](https://wsg.isceco.admin.ch/Livestock/AnimalTracingWSDL/3)

The generated XML is this (SOAP 1.1):

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://www.admin.ch/xmlns/Services/evd/Livestock/AnimalTracing/1" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <ns1:Body>
        <ns0:GetCodes>
            <ns0:p_ManufacturerKey xsi:nil="true"/>
            <ns0:p_LCID/>
            <ns0:p_Type xsi:nil="true"/>
        </ns0:GetCodes>
    </ns1:Body>
</SOAP-ENV:Envelope>

But the XML to be sent should be this (SOAP 1.2):

<SOAP-ENV:Envelope xmlns:ns1="http://www.admin.ch/xmlns/Services/evd/Livestock/AnimalTracing/1" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
    <SOAP-ENV:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <wsa:To>https://wsg.isceco.admin.ch/Livestock/AnimalTracing/3</wsa:To>
        <wsa:Action>http://www.admin.ch/xmlns/Services/evd/Livestock/AnimalTracing/1/AnimalTracingPortType/GetCodes</wsa:Action>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:GetCodes>
            <ns1:p_ManufacturerKey/>
            <ns1:p_LCID/>
            <ns1:p_Type/>
        </ns1:GetCodes>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
phillbaker commented 5 months ago

I took a quick look at the spec for soap 1.2 and it is quite different, so offhand I would say that the feature is not supported currently. Support for processing soap 1.2 replies has been added recently in #96 and #99, @eshizhan could you share how you're sending messages that receive soap 1.2 replies?

Otherwise, you could probably modify suds to have those features/construct the XML manually.

phillbaker commented 4 months ago

Here's an example approach from a stackoverflow/gist: https://stackoverflow.com/a/5262037 / https://gist.github.com/kgaughan/858851

A PR to incorporate that into the library would make sense to me.