Home » Python

Soaplib Python library, including WSDL generation

21 April 2007 No Comment

A while ago, I wrote about the ‘missing’ WSDL generator for Python. Today I found an interesting Python library for creating SOAP web services, soaplib. This two month old library has the following features:

  • simple syntax for writing services
  • comes with client and server built in
  • on-demand WSDL generation
  • plays well with other SOAP implementations
  • services can be deployed as WSGI applications
  • easily expose complex data structures
  • extensible Message API

The WSDL generation is done via decorators. If you do not know what decorators are, go read this). This makes it possible to write a simple Webservice in a few lines of code:

from soaplib.wsgi_soap import SimpleWSGISoapAppfrom soaplib.service import soapmethodfrom soaplib.serializers.primitive import String, Integer, Array

class HelloWorldService(SimpleWSGISoapApp):

    @soapmethod(String,Integer,_returns=Array(String))    def say_hello(self,name,times):        results = []        for i in range(0,times):            results.append('Hello, %s'%name)        return results

if __name__=='__main__':    from cherrypy._cpwsgiserver import CherryPyWSGIServer    # this example uses CherryPy2.2    server = CherryPyWSGIServer(('localhost',7789),HelloWorldService())    server.start()

This looks way cool and very simple to use! For more information, see the the full dissection of this example. I will try to use this library in one of my current projects.

Tweet This Post

Subscribe

Did you like this post? Subscribe for more!

Subscribe via RSS
(What is RSS?)

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.