PylonsHQ.

Layout: Fixed-width

ZSI Client for SOAP Controller with Optio's Soaplib

Unknown macro: {metadata-list}
Name ZSI Client for SOAP Controller with Optio's Soaplib
Space Pylons Cookbook
Section Controllers
Page ZSI Client for SOAP Controller with Optio's Soaplib
Version 1.0
Status Draft
Reviewed False
Author(s) 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']

Labels

soap soap Delete
soaplib soaplib Delete
controllers controllers Delete
recipes recipes Delete
sqlalchemy sqlalchemy Delete
zsi zsi Delete
wsdl wsdl Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Powered by Pylons - Contact Administrators