Time for action – creating the book warehousing process
Let's create the BookWarehousingBPEL
BPEL process:
- We will open the SOA composite by double-clicking on the Bookstore in the process tree. In the composite, we can see both Bookstore BPEL processes and their WSDL interfaces.
- We will add a new BPEL process by dragging-and-dropping the BPEL Process service component from the right-hand side toolbar.
- An already-familiar dialog window will open, where we will specify the BPEL 2.0 version, enter the process name as
BookWarehousingBPEL
, modify the namespace tohttp://packtpub.com/Bookstore/BookWarehousingBPEL
, and select Synchronous BPEL Process. We will leave all other fields to their default values: - Next, we will wire the
BookWarehousingBPEL
component with theBookstoreABPEL
andBookstoreBBPEL
components. This way, we will establish a partner link between them. First, we will create the wire to theBookstoreBBPEL
component (although the order doesn't matter). To do this, you have to click on the bottom-right side of the component. Once you place the mouse pointer above the component, circles on the edges will appear. You need to start with the circle labelled Drag to add a new Reference and connect it with the service interface circle, as shown in the following screenshot: - You do the same to wire the
BookWarehousingBPEL
component with theBookstoreABPEL
component: - We should see the following screenshot. Please notice that the
BookWarehousingBPEL
component is wired to theBookstoreABPEL
andBookstoreBBPEL
components:
What just happened?
We have added the BookWarehousingBPEL
component to our SOA composite and wired it to the BookstoreABPEL
and BookstoreBBPEL
components. Creating the wires between components means that references have been created and relations between components have been established. In other words, we have expressed that the BookWarehousingBPEL
component will be able to invoke the BookstoreABPEL
and BookstoreBBPEL
components. This is exactly what we want to achieve with our BookWarehousingBPEL
process, which will orchestrate both bookstore BPELs.
Once we have created the components and wired them accordingly, we are ready to implement the BookWarehousingBPEL
process.
Implementing the book warehousing BPEL
To implement the book warehousing BPEL process, we need to follow a few steps. As already mentioned, we have created a synchronous BPEL process.
Note
Every synchronous BPEL process starts with a <receive>
activity and ends with a <reply>
activity. In Chapter 5, Interaction Patterns in BPEL, we will learn about asynchronous BPEL processes. These do not need to return a response. If they want to return it, they can use a callback using the <invoke>
activity.
First, we have to define the XSD schema that will be used for the request and response messages. Let's suppose that the client will send the following data within the request message (the one received in the initial <receive>
activity):
- Data about the book, including the book's ISBN, title, edition, and publishing year
- Purchased quantity
The response of the book warehousing BPEL process will be relatively simple and will only include string
with the selected bookstore location.
Then, we will follow the process flow, which we defined earlier in this chapter. We will basically need to do the following:
- From the
<receive>
activity, we will prepare a request for both bookstore BPEL processes. We will use<assign>
for this. - We will invoke both bookstore BPEL processes (services) using
<invoke>
. - We will compare the response from both bookstore BPELs using
<if>
and create a reply.
To hold the request and response messages for BookstoreA
and BookstoreB
, we will need four variables: BookstoreARequest
, BookstoreAResponse
, BookstoreBRequest
, and BookstoreBResponse
. We will create these variables on the fly and discuss variables in more detail in Chapter 3, Variables, Data Manipulation, and Expressions.