Sending xml by SUDS

拥有回忆 提交于 2019-12-09 16:32:47

问题


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?


回答1:


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})


来源:https://stackoverflow.com/questions/21797389/sending-xml-by-suds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!