43dc2ebdc892751d43f519a8097e79c1.ppt
- Количество слайдов: 59
Devilish Web Services Composition and Orchestration Engine “Seminars in Software Engineering” course’s project 2007/2008 Professor Giuseppe De Giacomo Students: l Flavio Palandri antonelli l Alessandro Porfiri
Web Services Software modules designed to support interaction between heterogeneous systems in a network or in internet l l l public interface description of available operation Standard communication protocols Interaction via standard messages Great diffusion of Web Services systems Many functionalities already implemented and available
Scenario – Web Services Composition A client requires a TARGET service to be implemented All functionalities are already implemented in other AVAILABLE SERVICES Idea: we could realize the TARGET service combining Availables Service 1 mapping Service 2 Client Service request Community mapping Service n mapping
Objectives l Analyzing Services Composition Problem from a theoretical point of view l l Studying Web Services technologies Understanding tools already implemented to build automatically the composition ¡ ¡ l WSCE TLV Development of a tool able to manage the whole process ¡ ¡ ¡ Build Composition Generate and publish Target Service Manage the orchestration of services
Abstract services rapresentation l l We need to abstract from service implementation We rapresent only the service behavior TRANSTION SYSTEM
Composition actors l Available Services ¡ ¡ ¡ l Target ¡ ¡ ¡ l Existing services Rapresented by TS We will consider also non deterministic behavior Is the service requested by the client Rapresented by TS Only deterministic Orchestrator ¡ The composition manager
Composition
Who is orchestrator?
Build composition 1. Enconding the condition: in a PDL formula and checking its satisfability 2. Via Simulation Can we reproduce Target’s behavior with any one Available Services combination?
Simulation – The Community
Simulation Relation
Simulation Algorithm
Composition via simulation
Composition via simulation Composition exists iff Simulation exists
OG the Orchestrator Generator
Non deterministic behavior
Simulation with nondeterminism
OG with nondeterminism
TLV A tool for computing composition Temporal Logic Verifier l LTL based l Computes composition via simulation indirectly l Automatically computes the OG if realizable l Target + Community Comp-inv. pf Synth-inv. tlv TLV OG or “unrealizable”
TLV / 2 Target + Community file smw
TLV / 3 Simulation constraints:
TLV /4 If composition is realizable TLV’s output is the OG
How to create smw file? WSCE (web service composition engine) it’s like a wrapper for TLV l l l Creates smw file from target and available services TS descriptions Execute TLV on smw file From TLV result produce sql script to store the OG table into a DB WSCE TS descriptions WSTSL OG table TLV Script sql
WSCE /1 - Input TS of target and services are described with the xml language WSTSL
WSCE /2 - Output OG Table – one for each composition case STATE IN_ACT Target. State_S 1 State_S 2 State_S 3 OUT_ACT S 1 Login 0 0 1 S 2 search. By. Author 1 1 0 0 2 S 3 search. By. Title 1 1 0 0 3 S 4 Listen 2 1 1 0 2 S 5 Listen 2 1 0 1 3 Given in_act, Tstate and Si_states WSCE produce also NEXTSTATE[source, target] table Now, we just need to develop a tool able to manage the orchestration using this table
DIGRESSION – WS technologies Web services are software systems offering operations to remote clients l Available operations are described through the service interface WSDL l Clients communicate with service via SOAP messages on HTTP protocol l Example of a Java Web Service public class Login { int stato = 0; boolean loggedin; public String do. Login(String user)throws Exception{ if(stato != 0){ throw new Exception(“Illegal operation"); } stato = 1; loggedin = true; return “User logged in”; } public String do. Logout(String user)throws Exception{ if(stato != 1){ throw new Exception(“Illegal operation"); } stato = 0; loggedin = false; return “User logged out”; } login 0 1 logout }
DIGRESSION - Axis is a open source tool for l publishing web services (in this way software modules become WS) l Managing clients interaction with WS (request/response) It runs in a web container (Tomcat) To publish a service Axis needs Class files and the service’s descriptor file WSDD <deployment xmlns="http: //xml. apache. org/axis/wsdd/" xmlns: java="http: //xml. apache. org/axis/wsdd/providers/java"> <service name="urn: Login" provider="java: RPC"> <parameter name="class. Name" value=“service. Package. Login"/> <parameter name="allowed. Methods" value="do. Login, do. Logout"/> <parameter name="scope" value="Session"/> </service> </deployment> Publishing using command “java admin. Client login. wsdd” Service name Service class Service methods Conversation: Session = stateful Request = stateless Application = singleton
DIGRESSION – Service Interface Publishing the service, axis produce the service interface WSDL with all informations of service needed by clients l Service name and address l Methods ¡ ¡ l Output parameter Input parameters Complex. Type (any non standard Object managed by the service, example Person, Product, Order. . . ) WSDL are always accessible, to build the WS Target we will need all Available Services WSDL.
Our part in this project We want to complete the whole composition and orchestration process, developing missing elements l Orchestrator: a tool able to manage requests from Target Service, finding and delegating the operation to the right Available Service, using informations stored in the OG Table produced by WSCE. Basically Target will demand all client requests to the orchestrator l Target. Generator: a direct extension of WSCE, reading OG and Available Service WSDL produces and publishes the Target Web Service on Axis
Orchestrator /1 General Scenario Implementation of orchestrator program P(h, a) = i, and even more Client invokes Target operation Target demands client operation request to the orchestrator The Orchestrator access OG Table to find the index of the Available Service able to resolve the operation l The Orchestrator invoke the operation to selected service l Result is returned to client through Target Service. l l l To get the index of available service from the OG, the orchestrator needs: l Requested action l Target state l All Available Services states
Orchestrator /3 Services states Is orchestrator able to retrieve the status of services? l Target State: Yes always ¡ ¡ ¡ l Available Services states: depends ¡ ¡ l l l Target is deterministic Orchestrator can get Target initial state from OG Table At each step the orchestrator can get the new Target. State given “Input Action” and “Orchestrator State” using the NEXTSTATE table Deterministic: yes it could easily retrieve it from the OG Table Non deterministic: No, orchestrator must query all AS to retrieve their status Available Services have to manage their status They must offer a “int get. Status()” remote operation Connection with between Orchestrator and all services must be stateful
Orchestrator /2 Architecture - Unique component for every target (reuse) - An instance of orchestrator for each target - Orchestrator must be able to manage requests from Concurrent Clients
Orchestrator /4 Composition infos Orchestrator is indipendent from composition case The component must be usable from any target Target has to initialize his own orchestrator with composition infos: l Name of OG table l List of avalable service ¡ Service index ¡ Service name ¡ Service address l Complex type classes list
Orchestrator /5 Initialization Orchestrator Initialization: l Receives all informations from Target l For each Available Service establish a stateful connection: Call, mantained during the whole conversation with that client l Registers all Complex. Type’s classes Operation invocation l Using Calls to retrieve states from services l Using Call to invoke operation to selected service
Orchestrator /6 Concurrency Each Client has a Session with an instance of WS target Each Target has instance of orchestrator Each Orchestrator has a Session with every available services. This way Concurrency is guaranteed
Orchestrator /7 OP invocation Initialization: only for the first invocation Operation invocation
Orchestrator /8 Implementation
Orchestrator /9 Distribution Distributed as library Targets generated automatically are already made to use this library User can also build manually their own Target using Orchestrator’s API
Target Generator /1 How do we build the Target Service? • User can make the java class, publishing it manually • User can use the Target. Generator to build it in 1 minute INPUT • OG script provided by WSCE • WSDL files one for each available service OUTPUT • Target web service published on Axis ready to receive requests • OG Table stored in Mysql DB
Target Generator /2 Operations To register a service Axis needs class file of target service, wsdd file, class files of Complex. Type l l Creates java file of target and complextypes (ex person, product) Compiles all files Creates wsdd of target Publishes target service on Axis using “Admin. Client”
Target Generator /3 The whole process
Target Generator /4 Class Schema Target must import orchestrator. jar l Class header, class name is taken from input l Global variable of the Orchestrator l Constructor l ¡ Prepare all informations needed for composition l l l ¡ l OG tablename Array of Service. Info (name, address) //index is cabled in the array structure List of Complex. Types’ classes Orchestrator = new Orchestrator(tablename, service. Infos, complex. Types) Sequence of dummy methods representing remote operations of Service ¡ Method header l l ¡ ¡ Output parameter Input parameters Operation demanded to orchestrator, orchestrator. invoke(op) Result returned to client
Target Generator /5 Architecture All informations needed are retrieved from WSDL files of Available Services using WSDLParser
Target Generator /6 Execution flow
Target Generator /7 init Data Target Generator parses WSDL of Available Services to retrieve composition infos l Services name, address l Complex. Types l Methods
Running Tools l Example 1 – Test 1 ND: a Web Service to listen songs l Example 2 – Media. Store: tipical ECommerce application with interactive client l Other example can be found on the documentation
Example – Test 1 ND TS
Example – Test 1 ND Example of WSTSL Search. By. Author. ND. wstsl <? xml version="1. 0" encoding="UTF-8"? > <TS xmlns='http: //www. dis. uniroma 1. it/WS-TSL' xmlns: xsi='http: //www. w 3. org/2001/XMLSchema-instance' xsi: schema. Location='http: //www. dis. uniroma 1. it/WS-TSL file: /D: /sviluppo SW/FSMJ 5 Updated/FSM/ts. xsd' service="Search. By. Author. ND"> <STATE name="S 0" tipology="initial-final"> <TRANSITION action="Search. By. Author"> <TARGET state="S 1"></TARGET> <TARGET state="S 0"></TARGET> </TRANSITION> </STATE> <STATE name="S 1" tipology="transient"> <TRANSITION action="Listen"> <TARGET state="S 0"></TARGET> </TRANSITION> </STATE> </TS>
Example – Test 1 ND Java file of service l l l l l l l l l package test 1 NDCommunity; public class Search. By. Author. ND{ int stato = 0; public String Search. By. Author(String author) throws Exception{ if(stato != 0){ throw new Exception("Service is not able to execute this operation in this state"); } String canzone = ""; if(!author. equals("Paul")){ stato = 1; canzone = "yesterday"; } else{ //ND the service doesn't work with input Paul, keep state 0 canzone = "NOT FOUND"; } return canzone; } public String Listen(String name)throws Exception{ if(stato != 1){ throw new Exception("Service is not able to execute this operation in this state"); } stato = 0; return name+". . . yesterday, all my troubles seems so far away. . . "; } public int get. Status(){ return stato; } }
Example – Test 1 ND Example of WSDD Search. By. Author. ND. wsdd <deployment xmlns="http: //xml. apache. org/axis/wsdd/" xmlns: java="http: //xml. apache. org/axis/wsdd/providers/java"> <service name="urn: Search. By. Author. ND" provider="java: RPC"> <parameter name="class. Name" value="test 1 NDCommunity. Search. By. Author. ND"/> <parameter name="allowed. Methods" value="Search. By. Author, Listen, get. Status"/> <parameter name="scope" value="Session"/> </service> </deployment>
Example – Test 1 ND After published all service l User has to download WSDL of Available Service to prepare the wsdl directory 1 Execute WSCE l C: wsce-lite-dist_0. 1>java -jar wsce. jar test 1 ND 2 Generate target C: wsce-lite-dist_0. 1>java -jar targetgenerator. jar test 1 nd 3 Execute client l C: wsce-lite-dist_0. 1Composizionitest 1 NDservicesClient. Test 1 ND. java
Example – Media. Store Another example - TS
Example – Media. Store Example of WSTL Cart. Management. wstsl <? xml version="1. 0" encoding="UTF-8"? > <TS xmlns='http: //www. dis. uniroma 1. it/WS-TSL' xmlns: xsi='http: //www. w 3. org/2001/XMLSchema-instance' xsi: schema. Location='http: //www. dis. uniroma 1. it/WS-TSL file: /D: /sviluppo SW/FSMJ 5 Updated/FSM/ts. xsd' service="Cart. Management"> <STATE name="S 0" tipology="initial-final"> <TRANSITION action="add. To. Cart"> <TARGET state="S 0"></TARGET> </TRANSITION> <TRANSITION action="view. Cart"> <TARGET state="S 1"></TARGET> </TRANSITION> </STATE> <STATE name="S 1" tipology="final"> <TRANSITION action="remove. From. Cart"> <TARGET state="S 1"></TARGET> </TRANSITION> <TRANSITION action="add. To. Cart"> <TARGET state="S 1"></TARGET> </TRANSITION> <TRANSITION action="view. Cart"> <TARGET state="S 1"></TARGET> </TRANSITION> </STATE> </TS>
Example – Media. Store Example of WSDD with complex type Cart. Management. wsdd <deployment xmlns="http: //xml. apache. org/axis/wsdd/" xmlns: java="http: //xml. apache. org/axis/ wsdd/providers/java"> <service name="urn: Cart. Management" provider="java: RPC"> <parameter name="class. Name" value="media. Store. Community. Cart. Management "/> <parameter name="allowed. Methods" value="view. Cart, add. To. Cart, remove. From. Cart, get. Status"/> <parameter name="scope" value="Session"/> <bean. Mapping qname="my. NS: Product" xmlns: my. NS="urn: Cart. Management" language. Specific. Type="java: media. Store. Community. Product"/> </service> </deployment>
Example – Media. Store Java file of an Available Service Cart. Management. java package media. Store. Community; import java. util. *; public class Cart. Management { private int state = 0; private Vector cart; public Cart. Management() { cart = new Vector(); } public Vector view. Cart(){ state = 1; return cart; } public Product add. To. Cart(Product p){ cart. add(p); return p; } public void remove. From. Cart(Product p) throws Exception{ if(state!=1){ throw new Exception("Invalid operation request for this state"); } Iterator it = cart. iterator(); while(it. has. Next()){ Product p 2 = (Product)it. next(); if(p 2. get. Code() == p. get. Code()) it. remove(); } } public int get. Status(){ return state; } }
Example – Media. Store Java file of complex type Product. java package media. Store. Community; import java. io. *; public class Product implements Serializable{ private int code; String name; String type; double price; public Product(){ } public int get. Code(){ return code; } public void set. Code(int c){ code = c; } //set e get di tutti i metodi }
Example – Media. Store After published all service l java org. apache. axis. client. Admin. Client <file>. wsdd 1 Execute WSCE l C: wsce-lite-dist_0. 1>java -jar wsce. jar Media. Store 2 Generate target C: wsce-lite-dist_0. 1>java -jar targetgenerator. jar Media. Store 3 Execute client l C: wsce-lite-dist_0. 1ComposizioniMedia. StoreservicesClient. Media. Store. java
Media. Store. java Example – Media. Store package Media. Store; import orchestrator. *; import javax. xml. rpc. Service. Exception; import java. util. *; public class Media. Store { private Orchestrator orchestrator; private String tablename; public Media. Store() throws Exception{ tablename = "Media. Store"; Service. Info[] services = new Service. Info[4]; services[0] = new Service. Info("http: //127. 0. 0. 1: 8080/axis/services/", "urn: Cart. Management"); services[1] = new Service. Info("http: //127. 0. 0. 1: 8080/axis/services/", "urn: Product. List"); services[2] = new Service. Info("http: //127. 0. 0. 1: 8080/axis/services/", "urn: Check. Out. Service"); services[3] = new Service. Info("http: //127. 0. 0. 1: 8080/axis/services/", "urn: Buy. Service"); Linked. List<Class> complex. Types = new Linked. List<Class>(); complex. Types. add(Product. class); orchestrator = new Orchestrator( services, tablename, complex. Types); } public Product add. To. Cart(Product in 0)throws Exception{ Object[] params = {in 0}; Object risposta = orchestrator. invoke. Operation("add. To. Cart", params); return (Product)risposta; } public java. util. Vector view. Cart()throws Exception{ Object[] params = {}; Object risposta = orchestrator. invoke. Operation("view. Cart", params); return (java. util. Vector)risposta; } public void remove. From. Cart(Product in 0)throws Exception{ Object[] params = {in 0}; Object risposta = orchestrator. invoke. Operation("remove. From. Cart", params); } public java. util. Vector get. Product. List()throws Exception{ Object[] params = {}; Object risposta = orchestrator. invoke. Operation("get. Product. List", params); return (java. util. Vector)risposta; } public String buy(double in 0)throws Exception{ Object[] params = {in 0}; Object risposta = orchestrator. invoke. Operation(" buy", params); return (String)risposta; } public double check. Out(java. util. Vector in 0)throws Exception{ Object[] params = {in 0}; Object risposta = orchestrator. invoke. Operation("check. Out", params); return (Double)risposta; } public int get. Status(){ return orchestrator. get. Target. State(); } Target created }
Conclusions Users can build their Target Service in 5 minutes componing existing services l ¡ ¡ ¡ Build Target manually using orchestrator’s API Build Target automatically Complex. Types are managed The whole orchestration process is now completely working l ¡ ¡ Client concurrency Target itself may be an Available Service for another case of Composition Problems Available Services have to manage their state and offer the get. Status operation l We could spread in internet a “Componible” interface to be implemented l Extensions l l l Intergration of WSCE and Target. Generator The tool should be accessible remotely, with user friendly interface Extension to RMI services
43dc2ebdc892751d43f519a8097e79c1.ppt