Devilish Web Services Composition and Orchestration Engine

59
Devilish Web Services Composition and Orchestration Engine Students: Flavio Palandri antonelli Alessandro Porfiri “Seminars in Software Engineering” course’s project 2007/2008 Professor Giuseppe De Giacomo

description

Devilish Web Services Composition and Orchestration Engine. Students: Flavio Palandri antonelli Alessandro Porfiri. “Seminars in Software Engineering” course’s project 2007/2008 Professor Giuseppe De Giacomo. Web Services. - PowerPoint PPT Presentation

Transcript of Devilish Web Services Composition and Orchestration Engine

Page 1: Devilish Web Services Composition and Orchestration Engine

Devilish Web Services Composition and Orchestration Engine

Students: Flavio Palandri antonelli Alessandro Porfiri

“Seminars in Software Engineering” course’s project 2007/2008Professor Giuseppe De Giacomo

Page 2: Devilish Web Services Composition and Orchestration Engine

Web Services

Software modules designed to support interaction between heterogeneous systems in a network or in internet

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

Page 3: Devilish Web Services Composition and Orchestration Engine

ClientService request

Community

Service 1

Service n

mapping

Scenario – Web Services Composition

Service 2

mapping

mapping

A client requires a TARGET service to be implementedAll functionalities are already implemented in other AVAILABLE SERVICES

Idea: we could realize the TARGET service combining Availables

Page 4: Devilish Web Services Composition and Orchestration Engine

Objectives

Analyzing Services Composition Problem from a theoretical point of view

Studying Web Services technologies Understanding tools already implemented to build automatically the

composition WSCE TLV

Development of a tool able to manage the whole process Build Composition Generate and publish Target Service Manage the orchestration of services

Page 5: Devilish Web Services Composition and Orchestration Engine

Abstract services rapresentation

We need to abstract from service implementation We rapresent only the service behavior

TRANSTION SYSTEM

Page 6: Devilish Web Services Composition and Orchestration Engine

Composition actors

Available Services Existing services Rapresented by TS We will consider also non deterministic behavior

Target Is the service requested by the client Rapresented by TS Only deterministic

Orchestrator The composition manager

Page 7: Devilish Web Services Composition and Orchestration Engine

Composition

Page 8: Devilish Web Services Composition and Orchestration Engine

Who is orchestrator?

Page 9: Devilish Web Services Composition and Orchestration Engine

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?

Page 10: Devilish Web Services Composition and Orchestration Engine

Simulation – The Community

Page 11: Devilish Web Services Composition and Orchestration Engine

Simulation Relation

Page 12: Devilish Web Services Composition and Orchestration Engine

Simulation Algorithm

Page 13: Devilish Web Services Composition and Orchestration Engine

Composition via simulation

Page 14: Devilish Web Services Composition and Orchestration Engine

Composition via simulation

Composition exists iff Simulation exists

Page 15: Devilish Web Services Composition and Orchestration Engine

OG the Orchestrator Generator

Page 16: Devilish Web Services Composition and Orchestration Engine

Non deterministic behavior

Page 17: Devilish Web Services Composition and Orchestration Engine

Simulation with nondeterminism

Page 18: Devilish Web Services Composition and Orchestration Engine

OG with nondeterminism

Page 19: Devilish Web Services Composition and Orchestration Engine

TLV A tool for computing composition

Target + Community

Comp-inv.pf

Synth-inv.tlv

TLVOGor“unrealizable”

Temporal Logic Verifier LTL based Computes composition via simulation indirectly Automatically computes the OG if realizable

Page 20: Devilish Web Services Composition and Orchestration Engine

TLV / 2

Target + Communityfile smw

Page 21: Devilish Web Services Composition and Orchestration Engine

TLV / 3

Simulation constraints:

Page 22: Devilish Web Services Composition and Orchestration Engine

TLV /4

If composition is realizable TLV’s output is the OG

Page 23: Devilish Web Services Composition and Orchestration Engine

How to create smw file?

WSCE (web service composition engine) it’s like a wrapper for TLV

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

TLV

TS descriptions

WSTSL

OG table

Script sql

Page 24: Devilish Web Services Composition and Orchestration Engine

WSCE /1 - InputTS of target and services are described with the xml language WSTSL

Page 25: Devilish Web Services Composition and Orchestration Engine

WSCE /2 - Output

STATE IN_ACT TargetState State_S1 State_S2 State_S3 OUT_ACT

S1 Login 0 0 0 0 1

S2 searchByAuthor 1 1 0 0 2

S3 searchByTitle 1 1 0 0 3

S4 Listen 2 1 1 0 2

S5 Listen 2 1 0 1 3

OG Table – one for each composition case

WSCE produce also NEXTSTATE[source, target] table

Given in_act, Tstate and Si_states

Now, we just need to develop a tool able to manage the orchestration using this table

Page 26: Devilish Web Services Composition and Orchestration Engine

DIGRESSION – WS technologies

Web services are software systems offering operations to remote clients Available operations are described through the service interface WSDL Clients communicate with service via SOAP messages on HTTP protocol

Example of a Java Web Servicepublic class Login {

int stato = 0; boolean loggedin;

public String doLogin(String user)throws Exception{

if(stato != 0){

throw new Exception(“Illegal operation");

}

stato = 1; loggedin = true;

return “User logged in”;

}

public String doLogout(String user)throws Exception{

if(stato != 1){

throw new Exception(“Illegal operation");

}

stato = 0; loggedin = false;

return “User logged out”;

}

}

0 1login

logout

Page 27: Devilish Web Services Composition and Orchestration Engine

DIGRESSION - AxisAxis is a open source tool for publishing web services (in this way software modules become WS) 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="className" value=“servicePackage.Login"/>

<parameter name="allowedMethods" value="doLogin, doLogout"/>

<parameter name="scope" value="Session"/>

</service>

</deployment>

Service name

Service class

Service methods

Conversation:

Session = stateful

Request = stateless

Application = singleton

Publishing using command “java adminClient login.wsdd”

Page 28: Devilish Web Services Composition and Orchestration Engine

DIGRESSION – Service InterfacePublishing the service, axis produce the service interface WSDL with all

informations of service needed by clients Service name and address Methods

Output parameter Input parameters

ComplexType (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.

Page 29: Devilish Web Services Composition and Orchestration Engine

Our part in this project

We want to complete the whole composition and orchestration process, developing missing elements

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

TargetGenerator: a direct extension of WSCE, reading OG and Available Service WSDL produces and publishes the Target Web Service on Axis

Page 30: Devilish Web Services Composition and Orchestration Engine

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 The Orchestrator invoke the operation to selected service Result is returned to client through Target Service.

To get the index of available service from the OG, the orchestrator needs: Requested action Target state All Available Services states

Page 31: Devilish Web Services Composition and Orchestration Engine

Orchestrator /3 Services statesIs orchestrator able to retrieve the status of services?

Target State: Yes always Target is deterministic Orchestrator can get Target initial state from OG Table At each step the orchestrator can get the new TargetState given “Input Action”

and “Orchestrator State” using the NEXTSTATE table Available Services states: depends

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 getStatus()” remote operation Connection with between Orchestrator and all services must be stateful

Page 32: Devilish Web Services Composition and Orchestration Engine

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

Page 33: Devilish Web Services Composition and Orchestration Engine

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: Name of OG table List of avalable service

Service index Service name Service address

Complex type classes list

Page 34: Devilish Web Services Composition and Orchestration Engine

Orchestrator /5 Initialization

Orchestrator Initialization: Receives all informations from Target For each Available Service establish a stateful connection: Call, mantained

during the whole conversation with that client Registers all ComplexType’s classes

Operation invocation Using Calls to retrieve states from services Using Call to invoke operation to selected service

Page 35: Devilish Web Services Composition and Orchestration Engine

Orchestrator /6 ConcurrencyEach Client has a Session with an instance of WS targetEach Target has instance of orchestratorEach Orchestrator has a Session with every available services.

This way Concurrency is guaranteed

Page 36: Devilish Web Services Composition and Orchestration Engine

Orchestrator /7 OP invocation

Initialization: only for the first invocation

Operation invocation

Page 37: Devilish Web Services Composition and Orchestration Engine

Orchestrator /8 Implementation

Page 38: Devilish Web Services Composition and Orchestration Engine

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

Page 39: Devilish Web Services Composition and Orchestration Engine

Target Generator /1How do we build the Target Service?• User can make the java class, publishing it manually• User can use the TargetGenerator 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

Page 40: Devilish Web Services Composition and Orchestration Engine

Target Generator /2 Operations

To register a service Axis needs class file of target service, wsdd file, class files of ComplexType

Creates java file of target and complextypes (ex person, product) Compiles all files Creates wsdd of target Publishes target service on Axis using “AdminClient”

Page 41: Devilish Web Services Composition and Orchestration Engine

Target Generator /3 The whole process

Page 42: Devilish Web Services Composition and Orchestration Engine

Target Generator /4 Class Schema Target must import orchestrator.jar Class header, class name is taken from input Global variable of the Orchestrator Constructor

Prepare all informations needed for composition OG tablename Array of ServiceInfo (name, address) //index is cabled in the array structure List of ComplexTypes’ classes

Orchestrator = new Orchestrator(tablename, serviceInfos, complexTypes) Sequence of dummy methods representing remote operations of Service

Method header Output parameter Input parameters

Operation demanded to orchestrator, orchestrator.invoke(op) Result returned to client

Page 43: Devilish Web Services Composition and Orchestration Engine

Target Generator /5 Architecture

All informations needed are retrieved from WSDL files of Available Services using WSDLParser

Page 44: Devilish Web Services Composition and Orchestration Engine

Target Generator /6 Execution flow

Page 45: Devilish Web Services Composition and Orchestration Engine

Target Generator /7 init Data

Target Generator parses WSDL of Available Services to retrieve composition infos

Services name, address ComplexTypes Methods

Page 46: Devilish Web Services Composition and Orchestration Engine

Running Tools

Example 1 – Test1ND: a Web Service to listen songs

Example 2 – MediaStore: tipical E-Commerce application with interactive client

Other example can be found on the documentation

Page 47: Devilish Web Services Composition and Orchestration Engine

TS

Example – Test1ND

Page 48: Devilish Web Services Composition and Orchestration Engine

Example of WSTSL

SearchByAuthorND.wstsl

<?xml version="1.0" encoding="UTF-8"?><TS xmlns='http://www.dis.uniroma1.it/WS-TSL' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.dis.uniroma1.it/WS-TSL file:/D:/sviluppo SW/FSMJ5Updated/FSM/ts.xsd' service="SearchByAuthorND"> <STATE name="S0" tipology="initial-final"> <TRANSITION action="SearchByAuthor"> <TARGET state="S1"></TARGET>

<TARGET state="S0"></TARGET> </TRANSITION> </STATE> <STATE name="S1" tipology="transient"> <TRANSITION action="Listen"> <TARGET state="S0"></TARGET> </TRANSITION> </STATE></TS>

Example – Test1ND

Page 49: Devilish Web Services Composition and Orchestration Engine

Java file of service package test1NDCommunity; public class SearchByAuthorND{ int stato = 0; public String SearchByAuthor(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 getStatus(){ return stato; } }

Example – Test1ND

Page 50: Devilish Web Services Composition and Orchestration Engine

Example of WSDD

Example – Test1ND

SearchByAuthorND.wsdd

<deployment

xmlns="http://xml.apache.org/axis/wsdd/"

xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<service name="urn:SearchByAuthorND" provider="java:RPC">

<parameter name="className" value="test1NDCommunity.SearchByAuthorND"/>

<parameter name="allowedMethods" value="SearchByAuthor, Listen, getStatus"/>

<parameter name="scope" value="Session"/>

</service>

</deployment>

Page 51: Devilish Web Services Composition and Orchestration Engine

After published all service User has to download WSDL of Available Service to prepare the

wsdl directory

1 Execute WSCE C:\wsce-lite-dist_0.1>java -jar wsce.jar test1ND

2 Generate targetC:\wsce-lite-dist_0.1>java -jar targetgenerator.jar test1nd

3 Execute client C:\wsce-lite-dist_0.1\Composizioni\test1ND\services\ClientTest1ND.java

Example – Test1ND

Page 52: Devilish Web Services Composition and Orchestration Engine

Another example - TS

Example – MediaStore

Page 53: Devilish Web Services Composition and Orchestration Engine

Example of WSTL

Example – MediaStore

CartManagement.wstsl

<?xml version="1.0" encoding="UTF-8"?><TS xmlns='http://www.dis.uniroma1.it/WS-TSL' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.dis.uniroma1.it/WS-TSL file:/D:/sviluppo SW/FSMJ5Updated/FSM/ts.xsd' service="CartManagement"> <STATE name="S0" tipology="initial-final"> <TRANSITION action="addToCart"> <TARGET state="S0"></TARGET> </TRANSITION>

<TRANSITION action="viewCart"> <TARGET state="S1"></TARGET> </TRANSITION> </STATE> <STATE name="S1" tipology="final"> <TRANSITION action="removeFromCart"> <TARGET state="S1"></TARGET> </TRANSITION> <TRANSITION action="addToCart"> <TARGET state="S1"></TARGET> </TRANSITION> <TRANSITION action="viewCart"> <TARGET state="S1"></TARGET> </TRANSITION> </STATE></TS>

Page 54: Devilish Web Services Composition and Orchestration Engine

Example of WSDD with complex type

CartManagement.wsdd

<deploymentxmlns="http://xml.apache.org/axis/wsdd/"xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"><service name="urn:CartManagement" provider="java:RPC"><parameter name="className" value="mediaStoreCommunity.CartManagement"/><parameter name="allowedMethods" value="viewCart, addToCart, removeFromCart, getStatus"/><parameter name="scope" value="Session"/><beanMapping qname="myNS:Product" xmlns:myNS="urn:CartManagement" languageSpecificType="java:mediaStoreCommunity.Product"/></service></deployment>

Example – MediaStore

Page 55: Devilish Web Services Composition and Orchestration Engine

Java file of an Available Service

Example – MediaStore

CartManagement.java

package mediaStoreCommunity;import java.util.*;public class CartManagement {

private int state = 0;private Vector cart;

public CartManagement() { cart = new Vector(); } public Vector viewCart(){ state = 1; return cart; } public Product addToCart(Product p){ cart.add(p); return p; } public void removeFromCart(Product p) throws Exception{ if(state!=1){ throw new Exception("Invalid operation request for this state"); } Iterator it = cart.iterator(); while(it.hasNext()){ Product p2 = (Product)it.next(); if(p2.getCode() == p.getCode()) it.remove(); } } public int getStatus(){ return state; }}

Page 56: Devilish Web Services Composition and Orchestration Engine

Java file of complex type

Example – MediaStore

Product.java

package mediaStoreCommunity;import java.io.*;public class Product implements Serializable{

private int code;private String name;private String type;private double price;

public Product(){}

public int getCode(){return code;

}

public void setCode(int c){code = c;

} //set e get di tutti i metodi

}

Page 57: Devilish Web Services Composition and Orchestration Engine

After published all service java org.apache.axis.client.AdminClient <file>.wsdd

1 Execute WSCE C:\wsce-lite-dist_0.1>java -jar wsce.jar MediaStore

2 Generate targetC:\wsce-lite-dist_0.1>java -jar targetgenerator.jar MediaStore

3 Execute client C:\wsce-lite-dist_0.1\Composizioni\MediaStore\services\ClientMediaStore.java

Example – MediaStore

Page 58: Devilish Web Services Composition and Orchestration Engine

Target createdMediaStore.java

package MediaStore;import orchestrator.*;import javax.xml.rpc.ServiceException;import java.util.*;public class MediaStore {

private Orchestrator orchestrator;private String tablename;public MediaStore() throws Exception{

tablename = "MediaStore";ServiceInfo[] services = new ServiceInfo[4];services[0] = new ServiceInfo("http://127.0.0.1:8080/axis/services/", "urn:CartManagement");services[1] = new ServiceInfo("http://127.0.0.1:8080/axis/services/", "urn:ProductList");services[2] = new ServiceInfo("http://127.0.0.1:8080/axis/services/", "urn:CheckOutService");services[3] = new ServiceInfo("http://127.0.0.1:8080/axis/services/", "urn:BuyService");LinkedList<Class> complexTypes = new LinkedList<Class>();complexTypes.add(Product.class);orchestrator = new Orchestrator(services, tablename, complexTypes);

}public Product addToCart(Product in0)throws Exception{

Object[] params = {in0};Object risposta = orchestrator.invokeOperation("addToCart", params);return (Product)risposta;

}public java.util.Vector viewCart()throws Exception{

Object[] params = {};Object risposta = orchestrator.invokeOperation("viewCart", params);return (java.util.Vector)risposta;

}public void removeFromCart(Product in0)throws Exception{

Object[] params = {in0};Object risposta = orchestrator.invokeOperation("removeFromCart", params);

}public java.util.Vector getProductList()throws Exception{

Object[] params = {};Object risposta = orchestrator.invokeOperation("getProductList", params);return (java.util.Vector)risposta;

}public String buy(double in0)throws Exception{

Object[] params = {in0};Object risposta = orchestrator.invokeOperation("buy", params);return (String)risposta;

}public double checkOut(java.util.Vector in0)throws Exception{

Object[] params = {in0};Object risposta = orchestrator.invokeOperation("checkOut", params);return (Double)risposta;

}public int getStatus(){ return orchestrator.getTargetState(); }

}

Example – MediaStore

Page 59: Devilish Web Services Composition and Orchestration Engine

Conclusions Users can build their Target Service in 5 minutes componing existing services

Build Target manually using orchestrator’s API Build Target automatically ComplexTypes are managed

The whole orchestration process is now completely working 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 getStatus

operation We could spread in internet a “Componible” interface to be implemented

Extensions Intergration of WSCE and TargetGenerator The tool should be accessible remotely, with user friendly interface Extension to RMI services