Saturday, June 14, 2008

Python web service using SOAPPy

Here is an example of how to call a WebService from Python. For more information on Python and Web Services I recommend the following book: Python Cookbook.

This requires the fpconst and SOAPPy package. You can download them from http://research.warnes.net/projects/RStatServer/fpconst/ and http://prdownloads.sourceforge.net/pywebsvcs/SOAPpy-0.11.6.tar.gz?download. Unzip the packages then run python setup.py install on each package.

The following code will then connect to the web service and execute the remote method.

import sys

from SOAPpy import WSDL

url = 'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'
server = WSDL.Proxy(url);
print server.IsValidISBN13(sISBN ='0000000000000')



Note there is another web service package called ZSI, I found SOAPPy to be easier to use, but from what I understand both packages are going to merge together.

No comments: