SOAP (or Simple Object Access protocol) is a protocol that is used for development of web services in turn used for exchanging information across computers. While the message format is XML, the mode of negotiation and transmission typically is HTTP. SOAP provides a messaging framework where the client and web services are bind to a protocol and message format. More about SOAP can be read at wikipedia..

SOAP web services can be developed on top of web servers like Apache (*NIX) or IIS (Windows).. and of course Tornado web server! Let’s see how…

rancavil has come up with an excellent module that helps you develop SOAP based web services in Python and Tornado. This post describes development of SOAP Web Service on Tornado and a client program that can access this web service using Python-suds.

Let’s take an example

In this code snippet:

  • We create a SOAP Handler ‘MathService’ that performs mathematical operations
  • Method add() is defined that tales two integers as input and returns an integer value
  • Run the python code and the web service is up and running…
  • You could browse the WSDL at http://localhost:8080/MathService?wsdl

Let’s now have a look at the client code

  • The Client is developed with Python Suds module
  • It makes a request to the add() method of MathService with parameters 2 and 3
  • and waits for a response

Output of this code can be found below, where the response body contains the summation of 2 and 3 i.e., 5.


Request sent
<!--?xml version="1.0" encoding="UTF-8"?>
xmlns:ns0="" xmlns:xsi="" xmlns:SOAP-ENV="">

Response received
<!--?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xsi:schemaLocation="">