Rob
Rob

Reputation: 3459

SOAP client in python, how to replicate with XML

I am using suds to send XML and I got my request working, but I'm really confused by how to replicate my results using XML. I have the XML request that my suds client is sending by using:

from suds.client import Client
ulr = "xxxxxxx"
client = Client(url)

...

client.last_received.str()

but I'm not sure where I would send that request to if I was using the requests library. How would I replicate the request from the suds client in a python request?

Upvotes: 0

Views: 606

Answers (1)

Martin Konecny
Martin Konecny

Reputation: 59571

Most SOAP APIs are just over plain HTTP, use POST - and therefore are easily mimicked with any standard HTTP client such as Requests.

First look here to see how to view the headers and body that suds is sending - it is then a matter of replicating these headers/XML body and passing them into the Requests library.

One defining characteristic in 99% of all HTTP SOAP API's is that your request is going to the same end-point for each request (for example 'http://yyy.com:8080/Posting/LoadPosting.svc), and the actual action is specified in the header using SOAPAction header). Contrast this to a RESTful API where the action is implied with the verb + end-point you call (POST /user, GET /menu etc.)

Upvotes: 1

Related Questions