Sending xml by SUDS
Asked Answered
G

1

10

I would like to send my hand build xml by SUDS using WSDL. I found, that I can do it like that:

xml = Raw("""
<SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:GetAccountBalance>
         <ns0:Document>
            <myData>
                something
            </myData>
</ns0:Document>
      </ns0:GetAccountBalance>
   </ns1:Body>
</SOAP-ENV:Envelope>
    """)

print client.service.GetAccountBalance(xml)

But using this method SUDS sends:

<SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:GetAccountBalance>
         <ns0:Document>
            <SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:GetAccountBalance>
         <ns0:Document>
            <myData>
                something
            </myData>
</ns0:Document>
      </ns0:GetAccountBalance>
   </ns1:Body>
</SOAP-ENV:Envelope>
</ns0:Document>
      </ns0:GetAccountBalance>
   </ns1:Body>
</SOAP-ENV:Envelope>

My question is, how can I send my XML, without adding anything by SUDS?

Gelderland answered 15/2, 2014 at 12:13 Comment(0)
S
13

According to the suds documentation, you can send a raw SOAP message using the __inject argument to the method you're calling:

client.service.GetAccountBalance(__inject={'msg': xml})
Scylla answered 15/2, 2014 at 16:22 Comment(1)
I think what you're trying to say is that we have to substitute .GetAccoutBalance() with whatever method that we're trying to call. I got confused by the usage of the word "test" in the documentation also. It would be clearer to just say call the method you're trying to call using hand-made XML string.Sears

© 2022 - 2024 — McMap. All rights reserved.