Python Web/Grid Services - PowerPoint PPT Presentation

About This Presentation
Title:

Python Web/Grid Services

Description:

Python Web/Grid Services Presenter: Joshua Boverhof Lawrence Berkeley National Lab. – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 18
Provided by: Joshu137
Learn more at: https://dst.lbl.gov
Category:
Tags: artist | grid | name | python | services | web

less

Transcript and Presenter's Notes

Title: Python Web/Grid Services


1
Python Web/Grid Services
  • Presenter Joshua Boverhof
  • Lawrence Berkeley National Lab.

2
Project 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
3
Overview
  • 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

4
WSDL Info Items
ltservicegt
ltbindinggt
ltportTypegt
ltmesssagegt
lttypesgt
ltoperationgt
ltportgt
ltoperationgt
ltinputgt
ltinputgt
ltoutputgt
ltoutputgt
5
WSDL to Python
ltservicegt
ltbindinggt
ltportTypegt
ltmesssagegt
lttypesgt
ltoperationgt
ltportgt
ltoperationgt
ltpartgt
ltschemagt
Types
Locator
SOAPPort
elements
messages
6
TypeCodes 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 (maxOccursgt1)
    elements to be specified in sequences.

7
Elements, Types, and TypeCodes
WSDL from http//soap.systinet.net/demos/FreeDB/ws
dl
ltwsdlmessage name'FreeDBService_searchByTrack_R
esponse'gt ltwsdlpart name'response'
element'ns0ArrayOfCDInfo_Response'/gt
lt/wsdlmessagegt ltxsdelement name"ArrayOfCDInfo
_Response nillable"true type"xns4ArrayOfCDInf
o"/gt ltxsdcomplexType name"ArrayOfCDInfo"gt
ltxsdsequencegt
ltxsdelement maxOccurs"unbounded" minOccurs"0"
name"CDInfo"
nillable"true" type"tnsCDInfo"/gt
lt/xsdsequencegt lt/xsdcomplexTypegt
ltxsdcomplexType name"CDInfo"gt
ltxsdsequencegt ltxsdelement
name"artist" nillable"true type"xsdstring"/gt
ltxsdelement name"category"
nillable"true type"xsdstring"/gt
ltxsdelement name"discId" nillable"true
type"xsdstring"/gt
ltxsdelement name"title" nillable"true
type"xsdstring"/gt
lt/xsdsequencegt lt/xsdcomplexTypegt
8
Elements --gt XML Instance
lteEnvelope xmlnse"http//schemas.xmlsoap.org/so
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"gt
lteBodygt ltwn1ArrayOfCDInfo_Response
itype"wn0ArrayOfCDInfo"gt ltwn0CDInfo
itype"wn0CDInfo"gt ltwn0artist
itype"dstring"gtDeftones et Slipknotlt/wn0artist
gt ltwn0category itype"dstring"gtrocklt/wn
0categorygt ltwn0discId
itype"dstring"gt23110313lt/wn0discIdgt
ltwn0title itype"dstring"gtPersonnalisélt/wn0tit
legt lt/wn0CDInfogt lt/eBodygt lt/eEnvel
opegt
9
Generated Client Modules
_services.py
_types.py
Types
elements
Locator
SOAPPort
messages
wsdl2py -u http//soap.systinet.net/demos/FreeDB/
wsdl python gtgtgtfrom com_systinet_demo_freedb_Free
DBService_services import gtgtgtloc
JavaServiceLocator() gtgtgtport loc.getFreeDBServic
e() gtgtgtmsg port.searchByArtist(Slipknot') gtgtgt
msg ltcom_systinet_demo_freedb_FreeDBService_servic
es_types.ArrayOfCDInfo_Response_Decgt gtgtgt
len(msg._CDInfo) 74 gtgtgt msg._CDInfo49._title u'M
y Plague (New Abuse Mix)'
10
Generated 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 gtgtgtfrom com_systinet_demo_freed
b_FreeDBService_services_server import gtgtgtfrom
ZSI.ServiceContainer import AsServer gtgtgtAsServer(p
ort8080,services(com_systinet_demo_freedb_FreeDB
Service(),))
11
Service 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
12
New Directions pyGridWare
  • WS-Resource Stateless web services paradigm,
    implied factory pattern.
  • WS-Address Specify resource identity in SOAP
    Header.
  • Message-Level Security

13
Implied Resource Pattern
SoapHeader
Service
client
Body
1
Model State
create
2
epr
3
value
response
epr
5
epr
epr
4
epr
operation
14
Client 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

15
Create XML Instance
ltSOAP-ENVEnvelope xmlnsSOAP-ENC"http//schemas.
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/"gt
ltSOAP-ENVHeader xmlnsns1"http//schemas.xmlsoap
.org/ws/2003/03/addressing"gt ltns1MessageID
id"567080"gtuuid1087253160.24lt/ns1MessageIDgt
ltns1Action id"54e808"gthttp//counter.com/servic
e/CounterPortType/createCounterRequestlt/ns1Action
gt ltns1To id"73338"gthttp//bundy.localdomain
8080/wsrf/services/CounterServicelt/ns1Togt
lt/SOAP-ENVHeadergt ltSOAP-ENVBody
xmlnsns1"http//counter.com"gt
ltns1createCountergtlt/ns1createCountergt lt/SOAP-ENV
Bodygt lt/SOAP-ENVEnvelopegt
python gtgtgtimport pyGridWare.generated.stubs.Count
er_services as COUNTER gtgtgtlocator
COUNTER.CounterServiceLocator() gtgtgtport
locator.getCounterPortType() gtgtgtmsg
port.createCounter(COUNTER.CreateCounterRequest())
16
Create Response XML Instance
ltsoapenvEnvelope xmlnssoapenv"http//schemas.xm
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"gt
ltsoapenvHeadergt ltwsaMessageID
soapenvmustUnderstand"0"gtuuidE77B0490-BE5B-11D8
-92A0lt/wsaMessageIDgt ltwsaTo
soapenvmustUnderstand"0"gthttp//schemas.xmlsoap.
org/ws/2003/03/addressing/role/anonymouslt/wsaTogt
ltwsaAction soapenvmustUnderstand"0"gthttp//co
unter.com/service/CounterPortType/createCounterRes
ponse lt/wsaActiongt ltwsaFromgtltwsaAddressgthttp
//bundy.localdomain8080/wsrf/services/CounterServ
icelt/wsaAddressgtlt/wsaFromgt ltns0RelatesTo
RelationshipType"wsaResponse"
soapenvmustUnderstand"0"
xmlnsns0"http//schemas.xmlsoap.org/ws/2003/03/a
ddressing"gtuuid1087255976.97lt/ns0RelatesTogt
lt/soapenvHeadergt ltsoapenvBodygt
ltcreateCounterResponse xmlns"http//counter.com"gt
ltwsaEndpointReferencegt
ltwsaAddressgthttp//bundy.localdomain8080/wsrf/se
rvices/CounterServicelt/wsaAddressgt
ltwsaReferencePropertiesgt ltCounterKeygt2737873
5lt/CounterKeygt lt/wsaReferencePropertiesgt
lt/wsaEndpointReferencegt lt/createCounterResponse
gt lt/soapenvBodygt lt/soapenvEnvelopegt
17
Add Operation
ltSOAP-ENVEnvelope xmlnsSOAP-ENC"http//schemas.
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/"gt ltSOAP-E
NVHeader xmlnsns1"http//schemas.xmlsoap.org/ws
/2003/03/addressing" xmlnsns2"http//counter.com
"gt ltns1MessageID id"740980"gtuuid1088447466.
12lt/ns1MessageIDgt ltns1Action
id"55b610"gthttp//counter.com/service/CounterPort
Type/addRequestlt/ns1Actiongt ltns1To
id"107a260"gthttp//bundy.localdomain8080/wsrf/se
rvices/CounterServicelt/ns1Togt
ltns2CounterKey id"107a6b0"gt12399227lt/ns2Counter
Keygt lt/SOAP-ENVHeadergt ltSOAP-ENVBody
xmlnsns1"http//counter.com"gt ltns1add
id"18085d0"gt11lt/ns1addgt lt/SOAP-ENVBodygt lt/SOAP-
ENVEnvelopegt
gtgtgtmsg port.createCounter(COUNTER.CreateCounter
Request()) gtgtgtport locator.getCounterPortType(en
dPointReferencemsg._EndpointReference) gtgtgtmsg
port.add(11)
Write a Comment
User Comments (0)
About PowerShow.com