Python classes to XML/XSD

September 11th, 2011

If you want to test a python module that transforms python classes to XML and XSD documents look at:

Web Services and ComplexTypes

August 13th, 2011

It incorporates the mechanism for the use of python classes like xml complex types.

You must downloads and install the new release:

(Don't forget, you need have installed tornado web server).

In the example, the web service allows the consultation of products stored in a database.

Create the file

import tornado.httpserver
import tornado.ioloop
from tornadows import soaphandler
from tornadows import webservices
from tornadows import complextypes
from tornadows.soaphandler import webservice

class Input(complextypes.ComplexType):
idProduct = complextypes.IntegerProperty()

class Product(complextypes.ComplexType):
id = complextypes.IntegerProperty()
name = complextypes.StringProperty()
price = complextypes.FloatProperty()
stock = complextypes.IntegerProperty()

class ProductService(soaphandler.SoapHandler):
def getProduct(self, input):
id = input.idProduct.value

reg = self.database(id)

output = Product() = id = reg[0]
output.price.value = reg[1]
output.stock.value = reg[2]

return output

def database(self,id):
""" This method simulates a database of products """
db = {1:('COMPUTER',1000.5,100),
3:('PENCIL BLUE',0.50,500),
4:('PENCIL RED',0.50,600),
5:('PENCIL WHITE',0.50,900),
row = (None,0.0,0)
row = db[id]
return row

if __name__ == '__main__':
service = [('ProductService',ProductService)]
app = webservices.WebService(service)
ws = tornado.httpserver.HTTPServer(app)

Executing the service with.

$ python

You can see the WSDL from http://localhost:8080/ProductService?wsdl

For testing the service, you can use SoapUI or use python-suds.

You can use the next code:

import suds

url = 'http://localhost:8080/ProductService?wsdl'
client = suds.client.Client(url)

print client
# Param IdProduct, you can test with 1,2,3...
idProduct = 1
output = client.factory.create('Product')
output = client.service.getProduct(idProduct)

print 'Result'
print '---------------------------------'
print 'Id.Product : %d'
print 'Name Product : %s'
print 'Price : %f'%output.price
print 'Stock : %d'%output.stock
print '---------------------------------'

You need have installed python-suds, you can download it from:

Now, you can running the script for test the service.

Web Services in Python

June 29th, 2011

At last, i finished an simple and useful SOAP Web Service API to work on Tornado Web Server. You can download it from Github repository, or directly from

To install you must have Python 2.6+ and tornado 1.2.1+ (i have not tested with Python 3).

  1. Decompress the file tornadows-<version>.tar.gz
  2. Go into tornadows-<version> directory.
  3. Execute: python build
  4. Execute: python install

(I have tested it on Windows XP and Ubuntu, do not forget to use the sudo command on Ubuntu).

Now an simple first web service:

import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornadows import soaphandler
from tornadows import webservices
from tornadows import xmltypes
from tornadows.soaphandler import webservice

class SumService(soaphandler.SoapHandler):
def sum(self, a, b):
result = a + b
return result

if __name__ == '__main__':
service = [('SumService',SumService)]
app = webservices.WebService(service)
ws  = tornado.httpserver.HTTPServer(app)

Some features:

  1. This web service allows to sum of two integers.
  2. The WSDL is generated dynamically, you can get of http://localhost:8080/SumService?wsdl.
  3. I used soapUI tool to test this web service.
  4. In the file, XML types tested are: Integer and String

Finally, i am working in the ToDO list.



May 25th, 2011

Python has been a great programming language for developers, those who seek a flexible and easy mode to obtain fast and robust results. The reason is its simplicity and its big flexibility to extend the original features.

In the context of Internet, python has contributed with the development of a wide variety of frameworks and web servers,  today, i have been working a lot with tornado web server to develop the elements and components needed to develop and to publish SOAP web services.

My motivation is to develop a simple and practical manner for the design, development and implementation of web services, making use of the potentialities of tornado as web server. I hope to have soon a first usable version to publish in github.