[Answered ]-Django SOAP client

1👍

You basically have two options:

  • use a SOAP library like spyne. As you already noticed this isn’t much fun and tends to be a bit heavyweight (like tying your hand when it doesn’t hurt kind of approach);
  • do it "by hand".

What I mean with "by hand" is this: if the service you need to implement doesn’t require other WS-* specs (although if it did I doubt spyne could have helped much with that anyways) and it’s just plain SOAP requests and responses, then you can treat them like HTTP POST requests with an XML payload because that’s all they are. You receive an XML request and generate an XML response.

You can even use something like lxml to validate the SOAP request against an XML schema just to make sure things are properly sent by the external company (you already have the XML schema of the elements and operations you want inside the WSDL they sent you, so you can copy those parts from there; adding the rules for the SOAP envelope will not be too difficult). You could use a simpler SOAP library to build the messages or you can even implement a poor man’s solution with string concatenation.

You don’t need to implement the whole service from the WSDL you received, just use the WSDL as resource for how to properly format the XML messages. The rest is just handling HTTP requests and responses.

👤Bogdan

Leave a comment