3

I'm interfacing with a SOAP API, wherein a particular method requires a raw XML string as a parameter. Like so:

import suds.client as sudscl

client = sudscl.Client('http://host/ws.wsdl', location='http://host/ws')

session = 'test123'
options = '<rawXML><Item>Foobar</Item></rawXML>'

result = client.service.ExecuteSearch(session, options)

Pretty straight-forward. However, suds HTML-encodes the XML string I just sent in, like this:

 <?xml version="1.0" encoding="UTF-8"?>
 <SOAP-ENV:Envelope xmlns:ns0="http://host/ws">
   <SOAP-ENV:Header/>
   <ns1:Body>
     <ns0:ExecuteSearch>
        <ns0:session>test123</ns0:session>
        <ns0:options>
          &lt;rawXML&rt;&lt;Item&rt;Foobar&lt;/Item&rt;&lt;/rawXML&rt;
        </ns0:options>
     </ns0:ExecuteSearch>
   </ns1:Body>
 </SOAP-ENV:Envelope>

Boo! Is there any way to get suds to pass in the XML string un-altered?

Thanks!

Joshua Pruitt
  • 134
  • 2
  • 11
  • Does [this other answer](http://stackoverflow.com/a/21800232/1167750) help? – summea Jun 24 '15 at 00:27
  • @summea - Unfortunately, no. 1. This would require me to build and then pass in the entire SOAP message, when in fact I just want to pass in *one parameter* unmodified (not build the entire XML message from scratch). 2. __inject isn't working for me anyway (_TypeError: ExecuteSearch() got an unexpected keyword argument '__inject'_). – Joshua Pruitt Jun 24 '15 at 15:12

1 Answers1

3

Ok, got it.

from suds.sax.text import Raw
import suds.client as sudscl

client = sudscl.Client('http://host/ws.wsdl', location='http://host/ws')

session = 'test123'
options = Raw('<rawXML><Item>Foobar</Item></rawXML>')

result = client.service.ExecuteSearch(session, options)
Joshua Pruitt
  • 134
  • 2
  • 11