Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Python Web/Grid Services Presenter: Joshua Boverhof Lawrence Berkeley National Lab."— Presentation transcript:

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@lbl.gov Pywebsvcs-talk@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

5 WSDL to Python

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 (maxOccurs>1) elements to be specified in sequences.

7 Elements, Types, and TypeCodes <xsd:element maxOccurs="unbounded" minOccurs="0" name="CDInfo" nillable="true" type="tns:CDInfo"/> WSDL from http://soap. systinet.net/demos/FreeDB/wsdl http://soap. systinet.net/demos/FreeDB/wsdl

8 Elements --> XML Instance <e:Envelope xmlns:e="http://schemas.xmlsoap.org/soap/envelope/" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:wn0="http://systinet.com/wsdl/com/systinet/demo/freedb/" xmlns:wn1="http://systinet.com/xsd/SchemaTypes/" xmlns:wn2="http://idoox.com/interface"> Deftones et Slipknot rock 23110313 Personnalisé …

9 Generated Client Modules _services.py _types.py %wsdl2py -u http://soap.systinet.net/demos/FreeDB/wsdlhttp://soap.systinet.net/demos/FreeDB/wsdl %python >>>from com_systinet_demo_freedb_FreeDBService_services import * >>>loc = JavaServiceLocator() >>>port = loc.getFreeDBService() >>>msg = port.searchByArtist(’Slipknot') >>> msg >>> len(msg._CDInfo) 74 >>> msg._CDInfo[49]._title u'My Plague (New Abuse Mix)'

10 Generated Service Module _types.py %wsdl2dispatch -u http://soap.systinet.net/demos/FreeDB/wsdlhttp://soap.systinet.net/demos/FreeDB/wsdl %python >>>from com_systinet_demo_freedb_FreeDBService_services_server import * >>>from ZSI.ServiceContainer import AsServer >>>AsServer(port=8080,services=(com_systinet_demo_freedb_FreeDBService(),)) _services.py_services_server.py

11 Service Module class com_systinet_demo_freedb_FreeDBService(ServiceSOAPBinding): soapAction = { 'http://systinet.com/wsdl/com/systinet/demo/freedb/FreeDBService#getDetails#':'soap_getDetails', 'http://systinet.com/wsdl/com/systinet/demo/freedb/FreeDBService#search#':'soap_search', 'http://systinet.com/wsdl/com/systinet/demo/freedb/FreeDBService#searchByArtist#':'soap_searchByArtist', 'http://systinet.com/wsdl/com/systinet/demo/freedb/FreeDBService#searchByTitle#':'soap_searchByTitle', 'http://systinet.com/wsdl/com/systinet/demo/freedb/FreeDBService#searchByTrack#':'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._CDInfo[0]._title = 'My Plague (New Abuse Mix) ' response._CDInfo[0]._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 client Soap:Header Service Body 1 2 3 4 5 Model State

14 Client for WS-Resource $wsdl2py -f counter_service.wsdl -a 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

15 Create XML Instance <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> uuid:1087253160.24 http://counter.com/service/CounterPortType/createCounterRequest http://bundy.localdomain:8080/wsrf/services/CounterService %python >>>import pyGridWare.generated.stubs.Counter_services as COUNTER >>>locator = COUNTER.CounterServiceLocator() >>>port = locator.getCounterPortType() >>>msg = port.createCounter(COUNTER.CreateCounterRequest())

16 Create Response XML Instance <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing"> uuid:E77B0490-BE5B-11D8-92A0 http://schemas.xmlsoap.org/ws/2003/03/addressing/role/anonymous http://counter.com/service/CounterPortType/createCounterResponse http://bundy.localdomain:8080/wsrf/services/CounterService <ns0:RelatesTo RelationshipType="wsa:Response" soapenv:mustUnderstand="0" xmlns:ns0="http://schemas.xmlsoap.org/ws/2003/03/addressing">uuid:1087255976.97 http://bundy.localdomain:8080/wsrf/services/CounterService 27378735

17 Add Operation <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> uuid:1088447466.12 http://counter.com/service/CounterPortType/addRequest http://bundy.localdomain:8080/wsrf/services/CounterService 12399227 11 >>>msg = port.createCounter(COUNTER.CreateCounterRequest()) >>>port = locator.getCounterPortType(endPointReference=msg._EndpointReference) >>>msg = port.add(11)


Download ppt "Python Web/Grid Services Presenter: Joshua Boverhof Lawrence Berkeley National Lab."

Similar presentations


Ads by Google