Sneaking thru webservices like a python

After the brief presentation of php webservices, here’s how to play with SOAP and Python:

>>> from SOAPpy import SOAPProxy
>>> url = 'http://rpolli@babel.it:password@horde.example.com:80/rpc.php'
>>> n = 'urn:horde'
>>> server = SOAPProxy(url, namespace=n)     1
>>> server.config.dumpSOAPOut = 1            2
>>> server.config.dumpSOAPIn = 1
>>> calendars = server.calendar.list()    3

Steps are easy:

  1. set the namespace of the xml request: this is compulsory
  2. set I/O to verbose
  3. execute the call

You can list wsdl method with a similar way:

>>> from SOAPpy import WSDL          
>>> wsdlFile = 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl')
>>> server = WSDL.Proxy(wsdlFile)    
>>> server.methods.keys() 

Examples are taken from: 
http://www.diveintopython.org/soap_web_services/index.html