Title: Python WebGrid Services
1Python Web/Grid Services
- Presenter Joshua Boverhof
- Lawrence Berkeley National Lab.
2Project links
Webpage http//pywebsvcs.sourceforge.net/
http//dsd.lbl.gov/gtg/projects/download/download
_info.html Demo http//dsd.lbl.gov/boverhof
Email JRBoverhof_at_lbl.gov
Pywebsvcs-talk_at_lists.sourceforge.net
3Overview
- ZSI -- Zolera SOAP implementation
- wsdl2python -- WSDL/XML Schema
- Generate Client Locators, Ports, Messages
- Generate Service ServiceSOAPBinding
- pyGridWare -- WS-Resource Framework
- New Directions Basic Profile, WS-Addressing,
WS-Resource, XML Message Security
4WSDL Info Items
5WSDL to Python
Types
Locator
SOAPPort
elements
messages
6TypeCodes Describing the data
- ZSI.TypeCode aname specifies python attribute
name TypeCode will access for element value when
parsing and serializing. - --wsdl2py convention specify aname as _name
- Facets minOccurs, maxOccurs, nillable
- --ZSI TypeCodes expects repeatable (maxOccurs1)
elements to be specified in sequences.
7Elements, Types, and TypeCodes
WSDL from http//soap.systinet.net/demos/FreeDB/ws
dl
esponse' element'ns0ArrayOfCDInfo_Response'/
_Response nillable"true type"xns4ArrayOfCDInf
o"/
name"CDInfo"
nillable"true" type"tnsCDInfo"/
name"artist" nillable"true type"xsdstring"/
nillable"true type"xsdstring"/
type"xsdstring"/
type"xsdstring"/
8Elements -- XML Instance
ap/envelope/" xmlnsd"http//www.w3.org/2001
/XMLSchema" xmlnsi"http//www.w3.org/2001/X
MLSchema-instance" xmlnswn0"http//systinet
.com/wsdl/com/systinet/demo/freedb/"
xmlnswn1"http//systinet.com/xsd/SchemaTypes/"
xmlnswn2"http//idoox.com/interface"
itype"wn0ArrayOfCDInfo" itype"wn0CDInfo" itype"dstring"Deftones et Slipknot rock0category itype"dstring"23110313
Personnaliséle ope
9Generated Client Modules
_services.py
_types.py
Types
elements
Locator
SOAPPort
messages
wsdl2py -u http//soap.systinet.net/demos/FreeDB/
wsdl python from com_systinet_demo_freedb_Free
DBService_services import loc
JavaServiceLocator() port loc.getFreeDBServic
e() msg port.searchByArtist(Slipknot')
msg es_types.ArrayOfCDInfo_Response_Dec
len(msg._CDInfo) 74 msg._CDInfo49._title u'M
y Plague (New Abuse Mix)'
10Generated Service Module
_types.py
_services.py
_services_server.py
Types
elements
ServiceSOAP Binding
messages
wsdl2dispatch -u http//soap.systinet.net/demos/F
reeDB/wsdl python from com_systinet_demo_freed
b_FreeDBService_services_server import from
ZSI.ServiceContainer import AsServer AsServer(p
ort8080,services(com_systinet_demo_freedb_FreeDB
Service(),))
11Service Module
class com_systinet_demo_freedb_FreeDBService(Servi
ceSOAPBinding) soapAction
'http//systinet.com/wsdl/com/systinet/demo/freedb
/FreeDBServicegetDetails''soap_getDetails',
'http//systinet.com/wsdl/com/systinet/demo/f
reedb/FreeDBServicesearch''soap_search',
'http//systinet.com/wsdl/com/systinet/demo/free
db/FreeDBServicesearchByArtist''soap_searchByAr
tist', 'http//systinet.com/wsdl/com/systi
net/demo/freedb/FreeDBServicesearchByTitle''soa
p_searchByTitle', 'http//systinet.com/wsd
l/com/systinet/demo/freedb/FreeDBServicesearchByT
rack''soap_searchByTrack', def
__init__(self, post'/FreeDB/', kw)
ServiceSOAPBinding.__init__(self, post) def
soap_searchByArtist(self, ps) input
vals in request object args ps.Parse(
FreeDBService_searchByArtist_1_Request() )
assign return values to response object
response FreeDBService_searchByArtist_Response
() User Adds some logic to do something
if args Slipknot class
Holder pass response._CDInfo
Holder() response._CDInfo0._title
'My Plague (New Abuse Mix) '
response._CDInfo0._artist SLIPKNOT'
return response
12New Directions pyGridWare
- WS-Resource Stateless web services paradigm,
implied factory pattern. - WS-Address Specify resource identity in SOAP
Header. - Message-Level Security
13Implied Resource Pattern
SoapHeader
Service
client
Body
1
Model State
create
2
epr
3
value
response
epr
5
epr
epr
4
epr
operation
14Client for WS-Resource
- Client generated in same way Just specify
WS-Addressing - Create operation -- receives an EndpointReference
containing a - resource ID. This is used to refer back to
the stateful instance. - Drop EndpointReference into a new port.
- New port refers to a stateful service
- wsdl2py -f counter_service.wsdl -a
15Create XML Instance
xmlsoap.org/soap/encoding/"
xmlnsSOAP-ENV"http//schemas.xmlsoap.org/soap/en
velope/" xmlnsZSI"http//www.zolera.com/sch
emas/ZSI/" xmlnsxsd"http//www.w3.org/2001/XMLSc
hema" xmlnsxsi"http//www.w3.org/2001/XMLSc
hema-instance" SOAP-ENVencodingStyle"http/
/schemas.xmlsoap.org/soap/encoding/"
.org/ws/2003/03/addressing" id"567080"uuid1087253160.24
http//counter.com/servic
e/CounterPortType/createCounterRequest http//bundy.localdomain
8080/wsrf/services/CounterService
xmlnsns1"http//counter.com"
Body
python import pyGridWare.generated.stubs.Count
er_services as COUNTER locator
COUNTER.CounterServiceLocator() port
locator.getCounterPortType() msg
port.createCounter(COUNTER.CreateCounterRequest())
16Create Response XML Instance
lsoap.org/soap/envelope/" xmlnsxsd"http//www
.w3.org/2001/XMLSchema" xmlnsxsi"http//www.w3.o
rg/2001/XMLSchema-instance" xmlnswsa"http//s
chemas.xmlsoap.org/ws/2003/03/addressing"
soapenvmustUnderstand"0"uuidE77B0490-BE5B-11D8
-92A0 soapenvmustUnderstand"0"http//schemas.xmlsoap.
org/ws/2003/03/addressing/role/anonymous
http//co
unter.com/service/CounterPortType/createCounterRes
ponse http
//bundy.localdomain8080/wsrf/services/CounterServ
ice RelationshipType"wsaResponse"
soapenvmustUnderstand"0"
xmlnsns0"http//schemas.xmlsoap.org/ws/2003/03/a
ddressing"uuid1087255976.97
http//bundy.localdomain8080/wsrf/se
rvices/CounterService
2737873
5
17Add Operation
xmlsoap.org/soap/encoding/"
xmlnsSOAP-ENV"http//schemas.xmlsoap.org/soap/en
velope/" xmlnsZSI"http//www.zolera.com/sch
emas/ZSI/" xmlnsxsd"http//www.w3.org/2001/
XMLSchema" xmlnsxsi"http//www.w3.org/2001/
XMLSchema-instance" SOAP-ENVencodingStyle"h
ttp//schemas.xmlsoap.org/soap/encoding/" NVHeader xmlnsns1"http//schemas.xmlsoap.org/ws
/2003/03/addressing" xmlnsns2"http//counter.com
" uuid1088447466.
12 id"55b610"http//counter.com/service/CounterPort
Type/addRequest id"107a260"http//bundy.localdomain8080/wsrf/se
rvices/CounterService
12399227Key xmlnsns1"http//counter.com" id"18085d0"11 ENVEnvelope
msg port.createCounter(COUNTER.CreateCounter
Request()) port locator.getCounterPortType(en
dPointReferencemsg._EndpointReference) msg
port.add(11)