Understanding sequential invocation
Within the <process>
element, a BPEL process will usually have the top-level <sequence>
element. Within the sequence, the process will first wait for the incoming message to start the process. This wait is usually modeled with the <receive>
construct. It could also be modeled with the <pick>
activity, if we expect more than one incoming message. We will explain the <pick>
activity in Chapter 10, Events and Event Handlers.
Then, the process will invoke the related services using the <invoke>
construct. Such invocations can be done sequentially or in parallel. If we want to make them sequential, we simply write an <invoke>
activity for each invocation, and the services will be invoked in that order. Finally, the process will return a response using <reply>
. This is shown in the following code excerpt:
<process ...> ... <sequence> <!-- Wait for the incoming request to start the process --> <receive ... /> <!-- Invoke a set of related services, one by one --> <invoke ... /> <invoke ... /> <invoke ... /> ... <!-- Return the response --> <reply ... /> </sequence> </process>
A closer look at <invoke>
With <invoke>
, the BPEL process invokes operations on other services. We have to specify the following attributes:
partnerLink
: This specifies which partner link will be usedportType
: This specifies the used port typeoperation
: This specifies the name of the operation to invoke (<invoke>
)
When the business process invokes an operation on the service, it sends a set of parameters. These parameters are modeled as input messages with services. To specify the input message for the invocation, we use the inputVariable
attribute and specify a variable of the corresponding type.
If we invoke a synchronous request/response operation, it returns a result. This result is again a message, modeled as an output message. To store it in a variable, <invoke>
provides another attribute, called outputVariable
.
We can also specify a name
attribute. We use the name
attribute to provide names for activities.
The following code excerpt shows an example of the <invoke>
activity. We specify that the BPEL process should invoke the synchronous operation getBookData
on port type ns2:bookstoreABPEL
using the BookstoreABPEL
partner link, providing the input from the BookstoreARequest
variable and storing the output in the BookstoreAResponse
variable, as shown in the following screenshot: