Title: Service%20Oriented%20Architecture
1Service Oriented Architecture
- Lecture 7 BPEL
- Some notes selected from Business Process
Execution Language for Web Services by Matjaz
Juric
2We Are Here
From IBMs High Level Reference Architecture
3BPEL
- Business Process Execution Language
- Programming in the large
- Processing logic to handle synchronous and
asynchronous messages - Quite different from programming in the small -
different issues to deal with - Structured programming language
- using while, if else, sequence,
- flow,
- XPATH used for addressing message parts
4Basics
- Developing web services and exposing
functionalities is not sufficient. - Need a way to compose these functionalities in
the right order a way to define business
processes which will make use of the exposed
functionalities. - BPEL allows composition of web services.
- BPEL may be used for a long running process.
- Dehydration is the term used to refer to the
saving of a process state. - Successfully completed processes as well are
saved in the dehydration store.
5Web Service Composition Methods - Orchestration
- A central process takes control over the involved
web services and coordinates the execution of
different operations on the web services involved
in the operation. - This is done as per the requirements of the
orchestration. - The involved web services do not know (and do not
need to know) that they are involved into a
composition and that they are a part of a higher
business process. - Only the central coordinator of the orchestration
knows this. - So orchestration is centralized with explicit
definitions of operations and the order of
invocation of web services.
6Web Service Composition Methods - Choreography
- Choreography does not rely on a central
coordinator. - Each web service involved in the choreography
knows exactly when to execute its operations and
whom to interact with. - Choreography is a collaborative effort focused on
exchange of messages. - All participants of the choreography need to be
aware of the business process, operations to
execute, messages to exchange, and the timing of
message exchanges. - This is a peer-to-peer approach.
7Composing web services to execute business
processes
- Orchestration is the more flexible approach
compared to choreography - We know exactly who is responsible for the
execution of the whole business process. - We can incorporate web services, even those that
are not aware that they are a part of a business
process. - We can also provide alternative scenarios when
faults occur. - BPEL follows the orchestration paradigm.
- Choreography is covered by other standards, such
as WSCI (Web Services choreography Interface) and
WS-CDL (Web Services Choreography Description
Language). - Choreography has not gained support from the
industry which would be comparable to BPEL.
8Programming in the Large History
- IBM WSFL (Web Service Flow
- Language) defined in May 2001.
- Microsoft XLANG defined around the same time.
- Joint submission to OASIS under the name BPEL4WS.
- OASIS (September 2004) WS-BPEL-2.0.
- Has no standard graphical language.
- The BPEL process itself is a web service.
- BPEL business processes are portable.
9BPEL
- BPEL builds on top of XML and web services.
- It is an XML-based language which supports the
web services technology stack, including SOAP,
WSDL, UDDI, WS-Reliable Messaging, WS-Addressing,
WS-Coordination and WS-Transaction.
10 A typical BPEL process
- First, the BPEL business process receives a
request. - To fulfill it, the process then invokes the
involved web services and finally responds to the
original caller. - Since the BPEL process communicates with other
web services, it relies heavily on the WSDL
description of the web services invoked by the
composite web service.
11Steps in a Process
- Each step is called an activity.
- BPEL supports primitive and structure activities.
- Primitive activities represent basic constructs
and are used for common tasks
12Primitive Activities
- Invoking other web services, using ltinvokegt
- Waiting for the client to invoke the business
process through sending a message, using
ltreceivegt (receiving a request) - Generating a response for synchronous operations,
using ltreplygt - Manipulating data variables, using ltassigngt
- Indicating faults and exceptions, using ltthrowgt
- Waiting for some time, using ltwaitgt
- Terminating the entire process, using ltterminategt
etc.
13Defining Processes
- Combine these and other primitive activities and
define complex algorithms, which exactly specify
the steps of business processes. - To combine primitive activities BPEL supports
several structured activities
14Structured Activities
- Sequence ( ltsequencegt), which allows us to define
a set of activities that will be invoked in an
ordered sequence - Flow ( ltflowgt) for defining a set of activities
that will be invoked in parallel - Case-switch construct ( ltswitchgt) for
implementing branches - While ( ltwhilegt) for defining loops
- The ability to select one of a number of
alternative paths, using ltpickgt
15Definitions and Declarations
- BPEL processes will typically declare variables
using ltvariablegt - BPEL processes will typically define partner
links using ltpartnerLinkgt - A BPEL process can be synchronous or
asynchronous. - A synchronous BPEL process blocks the client (the
one which is using the process) until the process
finishes and returns a result to the client. - An asynchronous process does not block the
client. Rather it uses a callback to return the
result (if any)
16Example Process
- For its clients a BPEL process looks like any
other web service. - When we define a BPEL process, we actually define
a new web service that is a composition of
existing services. - The interface of the new BPEL composite web
service uses a set of port types, through which
it provides operations like any other web
service. - To invoke a business process described in BPEL,
we have to invoke the resulting composite web
service.
17(No Transcript)
18Typical Structure (1)
- ltprocessgt
- ltpartnerLinksgt
- ltpartnerLinkgt
- ltpartnerLinkgt
- lt/partnerLinksgt
- ltvariablesgt
- ltvariablegt
- ltvariablegt
- lt/variablegt
- ltsequencegt
- ltreceivegt the initial client
request - lt/receivegt
-
19Partner Links
- BPEL calls the links to all parties it interacts
with as partner links - Partner links can be links to web services that
are invoked by the BPEL process - Partner links can also be links to clients which
invoke the BPEL process - Each BPEL process has at least one client partner
link, because there has to be a client that
invokes the BPEL process.
20Typical Structure (2)
ltflowgt make calls in parallel
ltinvokegt a web service lt/invokegt
ltinvokegt another web service lt/invokegt
lt/flowgt
21Typical Structure (3)
ltswitchgt make decisions ltcase
condition gt ltassigngt
ltcopygt
ltfromgtlttogt lt/casegt
ltotherwisegt ltassigngt
ltcopygt
ltfromgtlttogt lt/otherwisegt
lt/switchgt ltreplygt reply
to synchronous caller lt/sequencegt lt/processgt
22Sequential Order of Activities
ltprocessgt . ltsequencegt Do activities in
sequential order. ltreceivegt
ltinvokegt ltassigngt ltinvokegt
ltreceivegt ltinvokegt
lt/sequencegt lt/processgt
23Parallel Activities
ltprocessgt . ltsequencegt
ltreceivegt Wait to start process ltflowgt
ltinvokegt
The three invokes are ltinvokegt
carried out in
ltinvokegt
parallel. lt/flowgt
lt/sequencegt lt/processgt
24 Parallel Sequences
ltprocessgt . ltsequencegt
ltreceivegt Wait to start process.
ltflowgt Both sequences may run in
parallel. ltsequencegt
ltinvokegt These two invokes go in order.
ltinvokegt
lt/sequencegt ltsequencegt
ltinvokegt These two invokes go in
order ltinvokegt
lt/sequencegt lt/flowgt
lt/sequencegt lt/processgt
25Synchronous Web Services
The sender blocks and waits for a reply. The
service should run fast. The ltreceivegt and
ltreplygt form a pair on B.
ltreceivegt
ltinvokegt
ltinvokegt..ltinvokegt
No ltreceivegt needed
B is a synchronous web service and uses a BPEL
reply.
ltreplygt
B
A
26Quiz on Synchronous Web Services
What does A need to know about B? In other words,
what is required in Bs WSDL?
ltreceivegt
ltinvokegt..ltinvokegt
ltinvokegt
No ltreceivegt needed.
B is a synchronous web service and uses a BPEL
reply.
ltreplygt
B
A
27Quiz on Synchronous Web Services
What does A need to know about B? In other words,
what is required in Bs WSDL? A needs to know
the message types and the available operations as
well as Bs location.
ltreceivegt
ltinvokegt..ltinvokegt
ltinvokegt
No ltreceivegt needed.
B is a synchronous web service and uses a BPEL
reply.
ltreplygt
B
A
28Asynchronous Web Services (1)
Most real-world processes are long running and
if callbacks are needed, message correlation may
be used. If callbacks are not needed, B need not
perform an ltinvokegt.
ltreceivegt
ltinvokegt
ltinvokegt..ltinvokegt
Do other things
B is an asynchronous web service and replies with
an optional invoke not a reply.
ltreceivegt
ltinvokegt
B
A
29Quiz on Asynchronous Web Services
What does A need to know in order to use B? In
other words, what information must be available
in Bs WSDL?
ltreceivegt
ltinvokegt
ltinvokegt..ltinvokegt
Do other things
B is an asynchronous web service and replies with
an optional invoke not a reply.
ltreceivegt
ltinvokegt
B
A
30Quiz on Asynchronous Web Services
What does A need to know in order to use B? In
other words, what information must be available
in Bs WSDL? A needs to know the message types
and the available operations as well as Bs
location. In order to use B, A must also know
exactly what operations it needs to provide and
what messages will be received.
ltreceivegt
ltinvokegt
ltinvokegt..ltinvokegt
Do other things
ltreceivegt
B is an asynchronous web service and replies with
an optional invoke not a reply.
ltinvokegt
B
A
31Example Business Process
Collect employee information (name, id, travel
plans, etc.). Determine an employees flying
status (first class or coach) and then determine
the cheaper of two airlines. Return
suggested flight to the employee.
32Modified Example from Juric Text
Employee Travel Status WS synchronous
ltreceivegt
ltinvokegt
ltinvokegt
Coach or first class
ltreceivegt
American Airlines WS asynchronous
ltinvokegt ltreceivegt ltinvokegt ltreceivegt
price
Delta Airlines WS asynchronous
ltinvokegt
price
Asynch Process for Business Travels
Asynchronous web service
33Partner Links
- Partner links describe links to partners.
- Partners might be
- (1) Services that invoke the BPEL process.
- (2) Services invoked by the BPEL process.
- (3) Services that play both roles - the BPEL
process -
invokes the service and -
the service -
invokes a callback on the -
BPEL process. -
34PartnerLinkTypes
- PartnerLinkTypes represent interactions between
the parties. - We have three types of interactions in the
airline example -
- (1) The client interacts with the BPEL
process. - (2) The BPEL process calls the employee status
- web service.
- (3) The BPEL process calls the two airline web
services - and expects callbacks from both.
35PartnerLinkTypes
- Within the BPEL process WSDL, we have two roles
defined - for one of the links
- ltpartnerLinkType name"travelLT"gt
- ltrole name"travelService"gt
The interface of the - ltportType name"tnsTravelApprovalPT" /gt
BPEL service is implemented - lt/rolegt
at the service. - ltrole name"travelServiceCustomer"gt
The interface of the - ltportType name"tnsClientCallbackPT" /gt
client callback is implemented - lt/rolegt
on the client. - lt/partnerLinkTypegt
Client callback interface
BPEL Process interface
travelLT Travel Link Type
36PartnerLinkTypes
- The employee status WS is synchronous so
- within the employee status WS WSDL we have one
role defined
ltpartnerLinkType name"employeeLT"gt ltrole
name"employeeTravelStatusService"gt ltportType
name"tnsEmployeeTravelStatusPT"
/gt lt/rolegt lt/partnerLinkTypegt
Interface of employee status web service.
employeeLT Employee Link Type
37PartnerLinkTypes
- The airline web services are asynchronous and so
- within the airline WS WSDLs we have two roles
defined
ltpartnerLinkType name"flightLT"gt ltrole
name"airlineService"gt ltportType
name"tnsFlightAvailabilityPT" /gt lt/rolegt
ltrole name"airlineCustomer"gt ltportType
name"tnsFlightCallbackPT" /gt
lt/rolegt lt/partnerLinkTypegt
Airline interface
Callees callback interface
flightLT Flight Link Type
38PartnerLinks Are in the BPEL (1)
ltpartnerLinksgt ltpartnerLink name"client"
partnerLinkType"trvtravelLT"
myRole"travelService"
partnerRole"travelServiceCustomer"/gt
ltpartnerLink name"employeeTravelStatus"
partnerLinkType"empemployeeLT"
partnerRole"employeeTravelStatusS
ervice"/gt ltpartnerLink name"AmericanAirlin
es" partnerLinkType"alnflight
LT" myRole"airlineCustomer"
partnerRole"airlineService"/gt
ltpartnerLink name"DeltaAirlines"
partnerLinkType"alnflightLT"
myRole"airlineCustomer"
partnerRole"airlineService"/gt
lt/partnerLinksgt
39PartnerLinks Are in the BPEL(2)
ltpartnerLinksgt ltpartnerLink name"client"
partnerLinkType"trvtravelLT"
myRole"travelService"
partnerRole"travelServiceCustomer"/gt
lt/partnerLinksgt
This partner link is of type travelLT. So,
two interfaces are involved. This process is the
travel service part. The partner implements the
client callback interface.
These names are defined in the partner link type
section.
40PartnerLinks Are in the BPEL(3)
ltpartnerLinksgt
ltpartnerLink name"employeeTravelStatus"
partnerLinkType"empemployeeLT"
partnerRole"employeeTravelStatusServi
ce"/gt lt/partnerLinksgt
This partner link is of type employeeLT. So, one
interface is involved, that is, the interface of
the employee status web service.
41PartnerLinks Are in the BPEL(4)
ltpartnerLinksgt
ltpartnerLink name"AmericanAirlines"
partnerLinkType"alnflightLT"
myRole"airlineCustomer"
partnerRole"airlineService"/gt
ltpartnerLink name"DeltaAirlines"
partnerLinkType"alnflightLT"
myRole"airlineCustomer"
partnerRole"airlineService"/gt lt/partnerLinksgt
Both of these partner links are of type flightLT.
As such, two interfaces are mentioned. The role
of this process is to provide the callback
(FlightCallbackPT) and the role the partner is
to provide the FlightAvailabilityPT.
42PartnerLinks Are in the BPEL(5)
ltpartnerLinksgt ltpartnerLink name"client"
partnerLinkType"trvtravelLT"
myRole"travelService"
partnerRole"travelServiceCustomer"/gt
ltpartnerLinkType name"travelLT"gt ltrole
name"travelService"gt
The interface of the ltportType
name"tnsTravelApprovalPT" /gt BPEL service
is implemented lt/rolegt
at the service. ltrole
name"travelServiceCustomer"gt
The interface of the ltportType
name"tnsClientCallbackPT" /gt client
callback is implemented lt/rolegt
on the
client. lt/partnerLinkTypegt
43PartnerLinks Are in the BPEL(6)
ltpartnerLink name"employeeTravelStatus"
partnerLinkType"empemployeeLT"
partnerRole"employeeTravelStatusServi
ce"/gt
ltpartnerLinkType name"employeeLT"gt ltrole
name"employeeTravelStatusService"gt
ltportType name"tnsEmployeeTravelStatusPT" /gt
lt/rolegt
44PartnerLinks Are in the BPEL(7)
ltpartnerLink name"AmericanAirlines"
partnerLinkType"alnflightLT"
myRole"airlineCustomer"
partnerRole"airlineService"/gt
ltpartnerLink name"DeltaAirlines"
partnerLinkType"alnflightLT"
myRole"airlineCustomer"
partnerRole"airlineService"/gt
ltpartnerLinkType name"flightLT"gt ltrole
name"airlineService"gt ltportType
name"tnsFlightAvailabilityPT" /gt lt/rolegt
ltrole name"airlineCustomer"gt ltportType
name"tnsFlightCallbackPT" /gt
lt/rolegt lt/partnerLinkTypegt
45Variables in BPEL
ltvariablesgt lt!-- input for this process
--gt ltvariable name"TravelRequest"
messageType"trvTravelRequestMessage"/gt
lt!-- input for the Employee Travel Status
Web service --gt ltvariable
name"EmployeeTravelStatusRequest"
messageType"empEmployeeTravelStatusRequestMessa
ge"/gt lt!-- output from the Employee Travel
Status Web service --gt ltvariable
name"EmployeeTravelStatusResponse"
messageType"empEmployeeTravelStatusResponseMes
sage"/gt
46Variables (2)
lt!-- input for American and Delta Web
services --gt ltvariable name"FlightDetails"
messageType"alnFlightTicketReque
stMessage"/gt lt!-- output from American
Airlines --gt ltvariable name"FlightResponseA
A" messageType"alnTravelResponse
Message"/gt lt!-- output from Delta Airlines
--gt ltvariable name"FlightResponseDA"
messageType"alnTravelResponseMessage"/
gt lt!-- output from BPEL process --gt
ltvariable name"TravelResponse"
messageType"alnTravelResponseMessage"/gt
lt/variablesgt
47BPEL Main Process (1)
ltsequencegt lt!-- Receive the initial
request for business travel from client --gt
ltreceive partnerLink"client"
portType"trvTravelApprovalPT"
operation"TravelApproval"
variable"TravelRequest"
createInstance"yes" /gt
48BPEL Main Process (2)
lt!-- Prepare the input for the Employee
Travel Status Web Service --gt ltassigngt
ltcopygt ltfrom variable"TravelRequest"
part"employee"/gt ltto
variable"EmployeeTravelStatusRequest"
part"employee"/gt lt/copygt lt/assigngt
49BPEL Main Process (3)
lt!-- Synchronously invoke the Employee
Travel Status Web Service --gt ltinvoke
partnerLink"employeeTravelStatus"
portType"empEmployeeTravelStatusPT"
operation"EmployeeTravelStatus"
inputVariable"EmployeeTravelStatusRequest"
outputVariable"EmployeeTravelStatusRespon
se" /gt
50BPEL Main Process (4)
lt!-- Prepare the input for the airlines.
The input comes from two variables.
--gt ltassigngt ltcopygt ltfrom
variable"TravelRequest" part"flightData"/gt
ltto variable"FlightDetails"
part"flightData"/gt lt/copygt
ltcopygt ltfrom variable"EmployeeTravelSta
tusResponse" part"travelClass"/gt ltto
variable"FlightDetails" part"travelClass"/gt
lt/copygt lt/assigngt
51BPEL Main Process (5)
lt!-- Make a concurrent invocation on both
airlines. --gt ltflowgt ltsequencegt
lt!-- Async invoke of the AA Web service
and wait for the callback--gt ltinvoke
partnerLink"AmericanAirlines"
portType"alnFlightAvailabilityPT"
operation"FlightAvailability"
inputVariable"FlightDetails" /gt
ltreceive partnerLink"AmericanAirlines"
portType"alnFlightCallbackPT"
operation"FlightTicketCallback"
variable"FlightResponseAA" /gt
lt/sequencegt
The receive operation must occur after the
invoke. Hence, the sequence tag is used.
52BPEL Main Process (6)
ltsequencegt lt!-- Async
invoke of the DA Web service and wait for the
callback--gt ltinvoke partnerLink"DeltaA
irlines" portType"alnFlightAvailab
ilityPT" operation"FlightAvailabili
ty" inputVariable"FlightDetails"
/gt ltreceive partnerLink"DeltaAirlines"
portType"alnFlightCallbackPT"
operation"FlightTicketCallback"
variable"FlightResponseDA" /gt
lt/sequencegt lt/flowgt
Only the flow is done in parallel. For the
sequence to complete, the airline must respond.
53BPEL Main Process (7)
lt!-- The airlines have responded. Select
the best offer and construct the
TravelResponse --gt ltswitchgt ltcase
condition"bpwsgetVariableData('FlightResponseAA'
, 'confirmationData','/co
nfirmationData/Price') lt
bpwsgetVariableData('FlightResponseDA',
'confirmationData','/confirmationD
ata/Price')"gt lt!-- Select American
Airlines --gt ltassigngt
ltcopygt ltfrom variable"FlightRespon
seAA" /gt ltto variable"TravelRespon
se" /gt lt/copygt lt/assigngt
lt/casegt
54BPEL Main Process (8)
ltotherwisegt lt!-- Select Delta
Airlines --gt ltassigngt
ltcopygt ltfrom variable"FlightRespon
seDA" /gt ltto variable"TravelRespon
se" /gt lt/copygt lt/assigngt
lt/otherwisegt lt/switchgt
55BPEL Main Process (9)
lt!-- Make a callback to the client
--gt ltinvoke partnerLink"client"
portType"trvClientCallbackPT"
operation"ClientCallback"
inputVariable"TravelResponse" /gt
lt/sequencegt lt/processgt
56Sketch of Working Process
sequence receive information
from employee assign assign
to variable invoke invoke
service to determine flying status assign
assign result to variable flow
Do sequences in parallel
sequence invoke call
airline A receive get price
for ticket sequence invoke
call airline B receive
get price for ticket switch
select cheaper flight invoke
inform the employee
57Would this work?
sequence receive flow assign
invoke assign invoke receive
invoke receive switch invoke
No. The previous slide had it right. Here, we
have not expressed the synchronization
dependencies between activities.
However, BPEL provides for more complex
concurrency scenarios using links. A single link
is specified with a source and a target.
58We Need To Add Links
sequence receive flow assign
assign before the invoke invoke
invoke before the assign assign
assign before the two invokes invoke
invoke before receive receive
receive before the switch invoke
invoke before receive receive
receive before the switch
switch invoke
59Sources and Targets In BPEL
ltsequencegt ltreceivegt ltflowgt
ltassigngt ltsource linkName A/gt
lt/assigngt ltinvokegt.
lttarget linkName A /gt ltsource
linkName B /gt Invoke before assign
lt/invokegt ltassigngt lttarget
linkName B /gt ltsource
linkName C /gt Assign before the two
ltsource linkName D /gt
invokes. lt/assigngt
Assign before invoke.
Link names are user defined and should be well
chosen.
60Sources and Targets
ltinvokegt lttarget
linkName C/gt ltsource linkName
E/gt lt/invokegt ltreceivegt
lttarget linkName E/gt
ltsource linkName G/gt lt/receivegt
ltinvokegt lttarget linkName
D/gt ltsource linkName F /gt
lt/invokegt
61Sources and Targets
ltreceivegt lttarget linkName
F/gt ltsource linkName H/gt
lt/receivegt ltswitchgt lttarget
linkName G/gt lttarget linkName
H/gt lt/switchgt lt/flowgt ltinvokegt
62Concurrency and Links
- The flow tag provides the ability to express
synchronization - dependencies between activities.
- In other words, we can specify what happens and
when. - Link definitions are placed within the flow
activity. For example, - ltflowgt
- ltlinksgt
- ltlink name A/gt
- ltlink name B /gt
- lt/linksgt
-
- Every link must be associated with exactly one
source and target. - A links target activity may only be performed
after the source - activity has completed.
- Transition conditions may be added for
additional confusion.