I've done the same. I couldn't figure out how to get the control of the request I wanted, and I couldn't get any answers here (I did ask) or anywhere else, so I wrote suds off and just hand coded the XML. It's particularly bad because I was porting from PHP and that code used a SOAP library that worked fine. And yes, I do look down on PHP, as everyone should. 

If I had time, and SOAP was more central to my needs, I'd consider forking suds and maintaining it myself. Not gonna happen.

My attitude about suds is, it's worth a try, and if you're lucky and it 'just works,' go with it, but don't invest a lot of time struggling with it.


On Wed, Oct 2, 2013 at 11:58 AM, Jeff Kunce <jjkunce@gmail.com> wrote:
I agree, in principle, with what Chris says.  But I have had so many problems with suds, that I often just send/receive/parse raw XML.

Basically, I:

1. use soapUI to get raw XML request strings.

2. create XML request string templates with %(paramName)s string replacement:
    xmlRequest = xmlRequestTemplate%{paramName:paramVal, ...}

3. use the python "requests" module (http://docs.python-requests.org/en/latest/) to do the soap call:
    import requests
    xmlResponse = requests.post(endpointURL, data=xmlRequest)

 4. use ElementTree (or substitute your favorite XML lib) to parse the response:
    import xml.etree.cElementTree as ET
    responseRoot - ET.fromstring(xmlResponse)
    returnCode = int(responseRoot.find('.//statusBlock/returnCode').text.strip())

That's just the bare bones.  I've created some classes for requests, responses and exceptions that encapsulate those things, with some error handling, etc.

Obviously, this subverts all the fancy stuff in SOAP.  But it also bypasses a lot of the headaches.  It also lets me use Soap 1.2 :)

I'm wondering if anyone else has thoughts on this approach.

Thanks.

  -- Jeff




On Mon, Sep 30, 2013 at 6:15 PM, Chris Sears <csears@gmail.com> wrote:
Hi David,

What you describe is not how things are normally done with Suds. Usually the body is automatically created by Suds by invoking methods that are defined in the WSDL. If you control the SOAP server endpoint and wanted to pass arbitrary XML, you could always create a custom method (eg sendXML) with a string parameter for the XML body you wanted to send. It's a bit hacky, and you'd have to make sure things were properly encoded, but it would work.

 - Chris



On Mon, Sep 30, 2013 at 4:16 PM, David Greco <David_Greco@harte-hanks.com> wrote:

I am using Suds as a client. Trying to get it to simply call a service/method with a prebuilt XML string for the body (but let Suds handle the soap-specific enveloping).  Is this doable? So far I accomplished it by manually adding the soap evenlope, header, and body tags around the xml. Is there a better way?

 

 

 


_______________________________________________
suds mailing list
suds@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/suds


_______________________________________________
suds mailing list
suds@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/suds


_______________________________________________
suds mailing list
suds@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/suds



--
blogs:
http://johnstoner.wordpress.com/
'In knowledge is power; in  wisdom, humility.'