|
2. Alternatively, the process service itself can invoke and interact with services that participate in the execution of a process.
|
|
|
Services that participate with a process are referred to as partner services, and are defined within the process description.
|
|
Once a BPEL4WS process has been invoked, an instance of this process remains in existence until execution has completed. Therefore, two interaction scenarios exist between the process services and external partner services:
|
• the partner service can invoke a new instance of a process
|
• the partner service can interact with an existing process instance
|
|
The latter scenario is accomplished through message correlation.
|
|
A BPEL4WS process description defines a workflow consisting of a sequence of events based on predefined conditions and embedded logic. Each step within a workflow is implemented through the use of a basic activity or a structured activity. Basic activities provide primitive workflow functions. Examples include:
|
• receive
|
• invoke
|
• reply
|
• throw
|
|
• wait
|
|
The first three (receive, invoke, and reply) enable interaction between a process service and partner services. When certain conditions are encountered by the process, exception handling routines can be executed. The throw activity forces a fault condition that shifts processing to the corresponding logic.
|
|
A form of scheduled execution can be provided using the wait activity. It essentially suspends processing of the overall activity for a specified amount of time, or until a certain date or time is reached.
|
|
BPEL4WS also supplies a set of structured activities that allow for the creation of workflow logic:
|
• sequence
|
• flow
|
• switch
|
|
• while
|
|
Structured activities essentially determine how basic activities are utilized. The order in which they are to be executed can be set using the parent sequence activity. This establishes a construct hosting a list of other activities that are launched in the sequence in which they appear. In contrast, the flow activity construct contains a list of activities that can be executed concurrently.
|
|
The switch and while activities provide conditional logic constructs, similar to the traditional select-case statement and the do-while loop, respectively.
|
|
Below is a simple scenario involving an external partner service, the BPEL4WS process service, and an additional service invoked by the process.
|
|
|
1. An external partner service contacts the BPEL4WS process service by sending it a message. The receive activity within the process description establishes an entry point for a message from this partner (A).
|
|
2. The logic within the process description then reacts to the arrival of this message by applying the invoke activity to interact with another partner service (B).
|
|
3. Once the invoke activity has completed, the process service responds to partner A’s original request using the reply activity.
|
|
Let’s take a closer look at a the internal structure of a process description.
|
|
This process root element hosts the entire process definition:
|
<process name="MyProcess"...>
<partnerLinks>
...
</partnerLinks>
<variables>
...
</variables>
<faultHandlers>
...
</faultHandlers>
<sequence>
...
</sequence>
</process>
|
|
A process definition can consist of collections of the following constructs:
|
• partnerLinks
|
• variables
|
• faultHandlers
|
|
• sequence
|
|
Let’s discuss each of these individually.
|
|
The partnerLinks collection of partnerLink constructs is used to represent partner services. This element assigns services a name used within the context of the process, and also allows for the allocation of roles.
|
<process name="MyProcess"...>
<partnerLinks>
<partnerLink name="OrderEntry" ...>
...
</partnerLink>
<partnerLink name="InventoryControl" ...>
...
</partnerLink>
</partnerLinks>
</process>
|
|
Many business processes will involve long-running tasks, often due to various intermediate conditions that must be met before the execution of the process can continue. In order to support lengthy process lifespans, a state information management system is required. For this purpose, BPEL4WS provides the variables element.
|
|
Within this construct you can establish variables with different scopes using individual variable element declarations. Variables that are global can be accessed from anywhere in the process definition. Variable values typically consist of messages that contain some piece of state information.
|
<process name="MyProcess"...>
<variables>
<variable xmlns:ORD="http://www.examples.ws/"
name="OrderStatus"
messageType="x:OrderStatus"/>
</variables>
</process>
|
|
When a long running business activity fails, a business process will typically revert to a compensation process — a form of exception handling that is encapsulated within the faultHandlers construct.
|
|
Using nested catch constructs, you can define different responses for various error conditions.
|
<process name="MyProcess"...>
<faultHandlers>
<catch faultName="x:condition1" faultVariable="err001">
...
</catch>
<catchAll>
...
</catchAll>
</faultHandlers>
</process>
|
|
Finally, let’s revisit our original interaction scenario that demonstrates the use of the receive, invoke, and reply activities. We’ll nest each activity construct within the sequence element in order to establish the order of execution.
|
<process name="MyProcess"...>
<sequence>
<receive partner=”partnerA”>
...
</receive>
<invoke partner=”partnerB”>
...
</invoke>
<reply partner=”partnerA”>
...
</reply>
</sequence>
</process>
|
|
Note the use of the partner attributes. Partner interaction is predefined within process workflows.
|