WordPress Websites for Engineers: Elevate Your Brand
Web Services - Business Process Execution Language
1. Web Services (NSWI145)
Lecture 09: WS BPEL
Martin Nečaský, Ph.D.
Faculty of Mathematics and Physics
Charles University in Prague, Czech Republic
Summer 2013
2. Core WS Technologies
SOAP
defines XML messaging protocol for basic web
service interoperability
WSDL
introduces common grammar for describing web
services
Summer 2013
3. Business Process Automation
ordering of activities with beginning and end
performed to achieve business outcome
has inputs and outputs
Summer 2013
4. Business Process Automation
WSDL provides only stateless model for
particular
request-response message exchange, or
uncorrelated one-way message exchange
typical model of business interaction
sequence of particular peer-to-peer message
exchanges
• request-response and/or one-way
stateful, long running interactions involving two or
more parties
Summer 2013
5. Business Process Automation
core WS technologies allow automation of
only particular message exchange
we need additional WS technologies to
support automation of whole business
processes
core terms
WS orchestration
WS choreography
Summer 2013
6. WS Orchestration
specifies an executable process
result is a web service
view of one party that controls the process
WS-BPEL: Web Services Business Process
Execution Language
Summer 2013
7. WS Choreography
specifies a sequence of messages between collaborating
partners and resources
how they should communicate with each other
not an executable process
no particular view of particular partner
WS-CDL: Web Services Choreography Description
Language
Summer 2013
8. BPEL
XML based language for orchestrating Web
Services
BPEL has two parts
extensions to WSDL
business process execution constructs
BPEL script (internal process specification) +
WSDL document (external process specification)
define new Web Service implemented as
orchestration of other Web Services
requires WSDL 1.1 (WSDL 2.0 not supported)
Summer 2013
9. Sample Process
Receive Purchase Order
Send Invoice
Check Credit Card
Process Payment
Calculate Purchase
Order Price
Arrange Logistics
Summer 2013
10. BPEL
BPEL process = Abstract Web Service
has WSDL description
• port types composed of operations with inputs and
outputs
• operates only on the level of WSDL portTypes
– no binding to concrete services specified by WS-BPEL process
description
orchestrates other web services
Summer 2013
11. Process Exposition with WSDL
exposes BPEL process as a web service
described with WSDL
WSDL 1.1 file with few restrictions and
extensions
restrictions
• no service and binding is defined
• only types, messages, port types with operations
Summer 2013
12. Process Exposition with WSDL
PurchaseOrder
Process
PurchaseOrder
PortType
sendPurchaseOrder
Operation
Customer
Purchase Order
Invoice
Summer 2013
14. Process Exposition with WSDL
WSDL 1.1 file with few restrictions and
extensions
extensions
• partner link type
– characterization of conversational relationships between
process and its partner
• partner link type between process and web service
utilized by process
– two participants (process and web service) each with own role
• partner link type between process and its client
– one participant (process) with own role
Summer 2013
18. Process Exposition with WSDL
element partnerLinkType
WSDL extension
specifies WSDL port types the process offers to and requires
from a partner service
attribute name
• unique name of the partner link type within the scope of the
WSDL description
two (typically) or one element role
• each specifies role one of the communicating services acts
• attribute name
– unique name of the role within the partner link type
• attribute portType
– specifies WSDL port type the service acting in this role must offer
Summer 2013
20. Process Exposition with WSDL
<wsdl:description xmlns:plnk =
"http://docs.oasis-open.org/wsbpel/2.0/plnktype">
...
<plnk:partnerLinkType name="PurchaseOrderRequestLinkType">
<plnk:role name="PurchaseOrderServiceRole"
portType="pos:PurchaseOrderPortType" />
</plnk:partnerLinkType>
</wsdl:description>
Summer 2013
21. Process Definition
root element process with four major sections:
partnerLinks section
• relationships from process to external partner services
variables section
• declaration of process data
faultHandlers section
• handlers for processing faults
main activity
• activity to be executed by the process
Summer 2013
22. Process Exposition with WSDL
<process xmlns =
"http://docs.oasis-open.org/wsbpel/2.0/
process/executable">
<partnerLinks>...</partnerLinks>
<variables>...</variables>
<faultHandlers>...</faultHandlers>
<!–- {MAIN ACTIVITY} -->
</process>
Summer 2013
23. Process Definition – Partner Link
specified by element partnerLink
models a link between the process and a
partner service
instance of a partner link type
attribute name
unique name of the partner link within the
process
attribute partnerLinkType
reference to the partner link type
Summer 2013
24. Process Definition – Partner Link
attribute myRole
references the role in the partner link type acted
by the process
attribute partnerRole
references the role in the partner link type acted
by the partner service
Summer 2013
25. Process Definition – Partner Link
<process>
<partnerLinks>
<partnerLink name="CreditCardLink"
partnerLinkType="pos:CreditCardLinkType"
myRole="CreditCardClientRole"
partnerRole="CreditCardServiceRole" />
...
</partnerLinks>
...
</process>
Summer 2013
26. Process Definition – Partner Link
<process>
<partnerLinks>
...
<partnerLink name="PurchaseOrderRequestLink"
partnerLinkType="pos:PurchaseOrderRequestLinkType"
myRole="PurchaseOrderServerRole" />
...
</partnerLinks>
...
</process>
Summer 2013
27. Process Definition – Variable
element variable
variables hold data that constitute the state of the
process
attribute name
• unique variable name
content type of the variable specified as WSDL
message type, XSD element or XSD simple/complex
type
• attribute messageType
– reference to WSDL message type
• attribute element
– reference to XSD element declaration
• attribute type
– reference to XSD simple/complex type definition
Summer 2013
29. Process Definition - Activities
specify the process itself (main activity) or fault handling
several types of activities:
messaging activities
• invoke, receive, reply, assign, …
structured activities
• sequence, flow, if, while, …
fault activities
• throw, exit, …
compensation activities
• compensate, …
Summer 2013
30. Process Definition – invoke
allows business process to call a partner service
invokes one-way or request-response operation on a partner's port
type
attribute partnerLink
specifies invoked partner port type
attribute operation
specifies invoked operation of the partner port type
attribute inputVariable
specifies variable with the input message
can be replaced by toParts element with toPart child elements if
the input message has more parts
attribute outputVariable
specifies variable with the output message
can be replaced by fromParts element with fromPart child
elements if the output message has more parts
Summer 2013
32. Process Definition – receive
allows business process to receive a message
from a partner service
blocking activity
attribute partnerLink
specifies port type of the process that is awaited
to be invoked by the partner
attribute operation
specifies operation of the port type that is awaited
to be invoked by the partner
Summer 2013
33. Process Definition – receive
attribute variable
specifies variable where the arrival message will
be assigned
attribute createInstance
"yes"/"no" value
if "yes" the activity creates new process
instance
Summer 2013
35. Process Definition – reply
allows business process to send a message in
a reply to a message that was received by
receive
similar structure to invoke
Summer 2013
37. Process Definition – receive/reply
implements request/response message
exchange pattern
it is a pair
if there are more pairs, distinguish them by
attribute messageExchange
Summer 2013
38. Process Definition – assign
allows updating values of variables with new
data
copying data from one variable to another
construct new data and copy them to a variable
type validity checked
element copy
element from
element to
Summer 2013
39. Process Definition – assign
several variants of from and to:
1. from variable to variable
<assign>
<copy>
<from variable="c1" />
<to variable="c2" />
</copy>
</assign>
Summer 2013
40. Process Definition – assign
several variants of from and to:
2. from variable part to variable
<assign>
<copy>
<from>$c1/lines/line[1]</from>
<to variable="c2" />
</copy>
</assign>
Summer 2013
41. Process Definition – assign
several variants of from and to:
3. from XSLT script to variable
<assign>
<copy>
<from>bpel:doXslTransform(".../t.xsl", $c1)</from>
<to variable="c2" />
</copy>
</assign>
Summer 2013
42. Process Definition – sequence
specifies activities to be performed
sequentially
Summer 2013
46. Process Definition – flow
element link
declares synchronization dependency for flow
attribute name
• identifies dependency within flow
Summer 2013
48. Process Definition – flow
each activity may contain sources with one or more
source and targets with one or more target
establish synchronization relations via links
element source
attribute linkName - specifies that the activity is source
activity of the link
element target
attribute linkName - specifies that the activity is target
activity of the link
Summer 2013
49. Process Definition – flow
for a given link, its target activities must wait
until its source activities have finished
Summer 2013
54. Process Definition – flow
element transitionCondition in
source
contains logical expression specifying condition for
setting the link to true (additional condition to
"being finished")
Summer 2013
56. Process Definition – scope
allows definition of local partner
links, variables and activities
Summer 2013
57. Process Definition – if
used to select exactly one activity from given branches
branch = activity
first branch is directly as child
element condition
contains logical expression
condition for first branch activity
element elseif
element condition
other branch activity under a condition
element else
last branch
Summer 2013
58. Process Definition – if
<if>
<invoke>...</invoke>
<condition>$PaymentMessage/price > 1000</condition>
<elseif>
<invoke>...</invoke>
<condition>$PaymentMessage/price>500</condition>
</elseif>
<else>
<invoke>...</invoke>
</else>
</if>
Summer 2013
59. Process Definition – while
used to define that the child activity is to be
repeated as long as the specified condition is
true
element condition
contains logical expression
Summer 2013
60. Process Definition – while
<while>
<condition>$c1 > 1000</condition>
<sequence>
<invoke>...</invoke>
<assign>
<from>...</from>
<to>$c1</to>
</assign>
</sequence>
</while>
Summer 2013
61. Process Definition – forEach
iterates its child scope exactly N+1 times
where N is given by finalCounterValue
child element minus startCounterValue
child element
iterated activity is in the child scope
attribute parallel
"yes"/"no" value
if "yes" iterations are performed in parallel
flow with N+1 activities each for one iteration
Summer 2013
62. Process Definition – forEach
<forEach parallel="yes" countername="n">
<startCounterValue>1</startCounterValue>
<finalCounterValue>
count($PurchaseOrder//item)
</finalCounterValue>
<scope>
... variable $n with actual counter value ...
... iterated activity ...
</scope>
</forEach>
Summer 2013
63. Advanced Concepts
not presented in this lecture:
fault handling
event handling
terminating processes
undoing completed work (i.e. compensations)
message correlation
dynamic partner resolution
abstract processes
Summer 2013