Latest Version: 0.9.6.2
  Dashboard > Pylons Cookbook > ... > Controllers > ZSI Client for SOAP Controller with Optio's Soaplib
  Pylons Cookbook Log In | Sign Up   View a printable version of the current page.  
  ZSI Client for SOAP Controller with Optio's Soaplib
Added by Lysander David, last edited by Lysander David on Mar 18, 2008
Labels: 

Name Space Section Page Version Status Reviewed Author(s)
ZSI Client for SOAP Controller with Optio's Soaplib Pylons Cookbook Controllers ZSI Client for SOAP Controller with Optio's Soaplib 1.0 Draft False Lysander David

Introduction

In order to consume soaplib webservices without requiring the distribution
of the python source, it is possible to convert the wsdl for the service
into python using ZSI (http://sourceforge.net/projects/pywebsvcs).

This also assumes that the service specified in
Making a SOAP Controller with Optio's Soaplib is running.

Install ZSI

Download the tar.gz file from sourceforge, extract and install ZSI

1
2
3
wget http://superb-east.dl.sourceforge.net/sourceforge/pywebsvcs/ZSI-2.1-a1.tar.gz
cd ZSI-2.1-a1
python setup.py install

Generate Python from WSDL

Create a working directory, create a directory for the generated files then
generate the python files for the service.

1
2
3
mkdir -p ~/explore/python/pylons/03_hello_soap_client/gen_lib
cd ~/explore/python/pylons/03_hello_soap_client/gen_lib
wsdl2py -b  http://localhost:5000/soapy.wsdl

After running these commands you should see these files

1
2
HelloWorldService_client.py  HelloWorldService_types.py
HelloWorldService_server.py

which have been generated from the wsdl file for the soap service.

Execute the SOAP service using the classes generated from the WSDL

Create a file named say_hello.py in the parent directory of the
gen_lib directory

say_hello.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import sys
sys.path.insert(0,'gen_lib')
from HelloWorldService_client import HelloWorldServiceLocator, say_hello

loc = HelloWorldServiceLocator()

svc = loc.getHelloWorldService()

req = say_hello()
req._name = 'frank'
req._times = 5

resp = svc.say_hello(req)._retval._string

print resp

After executing the file, you should see something like this:

1
2
ldavid@ldavid-lap:~/explore/python/pylons/03_hello_soap_client $ python say_hello.py
['Hello, frank', 'Hello, frank', 'Hello, frank', 'Hello, frank', 'Hello, frank']

Site running on a free Atlassian Confluence Open Source Project License granted to Pylons. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.3.3 Build:#645 Feb 13, 2007) - Bug/feature request - Contact Administrators
Top