Let's start with the implementation of the BookWarehousingBPEL
process. We should follow these steps:
BookWarehousingBPEL.xsd
file (in the Schemas
folder) and write the following schema, as shown:BookWarehousingBPEL.bpel
). First, we will add an <assign>
activity to prepare a request for both the bookstore BPEL processes. In <assign>
, we will copy the whole BookData
element from inputVariable
to a new variable, which we will create on the fly. We should do the following:<assign>
to the BPEL process between the <receive>
and <reply>
activities.<assign>
activity to open the dialog window.BookstoreARequest
. As the type, we will choose Message Type, as we will prepare the whole message, which will be sent as a request message to BookstoreABPEL
. We will click on the magnifier icon to browse the message types and select BookstoreABPELRequestMessage
, as shown:BookstoreABPEL
. We will repeat the same steps as before. We will name the variable BookstoreAResponse
:BookstoreBRequest
and BookstoreBResponse
. In order to do this, we will repeat steps 3-5.BookData
element from inputVariable
to the BookData
element of the BookstoreARequest
variable. We need to do the copy element by element, as BookData
from inputVariable
belongs to a different namespace rather than the BookData
element from the BookstoreARequest
variable. Therefore, we will need to do four drag-and-drops. In the next chapter, we will explain how we could use the same namespace and simply copy the whole complex element as one, as shown in the following screenshot:BookstoreBRequest
variable.<assign>
activity from Assign1
to PrepareRequest
.BookstoreABPEL
. To invoke an external service, we will use the <invoke>
activity. We will drag the Invoke activity from the right-hand side toolbar and drop it on the process flow after <assign>
, which we've just added.<invoke>
activity with the BookstoreABPEL
service, listed in the right-hand side of the canvas (under the Partner Links section):BookstoreAInvoke
. The partner link, the port type, and the operation are already selected. We should leave the default values. The operation name is getBookData
, which is exactly what we are looking for.BookstoreARequest
variable. The output variable is the variable that stores the invocation response. This is BookstoreAResponse
. Let's select both variables, as shown in the following screenshot:BookstoreBBPEL
and use the corresponding BookstoreB
variables. This should bring us to the following BPEL process flow:<if>
activity to compare the response from both the bookstore BPELs and select the bookstore with the lower stock to ship the purchased books.<if>
activity in the previous chapter. First, we add the <if>
activity:<if>
activity and select Edit, as shown in the following screenshot. In the opened dialog box, we create a condition such that BookstoreAResponse
stock quantity is lower than the BookstoreBResponse
stock quantity. In this case, we select Bookstore A:<assign>
to set the appropriate response for the book warehousing BPEL process:We implemented the process flow logic for the BookWarehousingBPEL
process. It actually orchestrated two other services. It invoked the BookstoreA
and BookstoreB
BPEL processes that we developed in the previous chapter. Here, these two BPEL processes acted like services.
First, we created the XML schema elements for the request and response messages of the BPEL process. We created four variables: BookstoreARequest
, BookstoreAResponse
, BookstoreBRequest
, and BookstoreBResponse
. The BPEL code for variable declaration looks like the code shown in the following screenshot:
Then, we added the <assign>
activity to prepare a request for both the bookstore BPEL processes. Then, we copied the BookData
element from inputVariable
to the BookstoreARequest
and BookstoreBRequest
variables. The following BPEL code has been generated:
Next, we invoked both the bookstore BPEL services using the <invoke>
activity. The BPEL source code reads like the following screenshot:
Finally, we added the <if>
activity to select the bookstore with the lowest stock quantity:
With this, we have concluded the development of the book warehousing BPEL process and are ready to deploy and test it.
We will deploy the project to the SOA Suite process server the same way we did in the previous chapter, by right-clicking on the project and selecting Deploy. Then, we will navigate through the options. As we redeploy the whole SOA composite, make sure the Overwrite option is selected. You should check if the compilation and the deployment have been successful.
Then, we will log in to the Enterprise Manager console, select the project bookstore, and click on the Test button. Be sure to select bookwarehousingbpel_client
for the test. After entering the parameters, as shown in the following screenshot, we can click on the Test Web Service button to initiate the BPEL process, and we should receive an answer (Bookstore A or Bookstore B, depending on the data that we have entered).
Remember that our BookWarehousingBPEL
process actually orchestrated two other services. It invoked the BookstoreA
and BookstoreB
BPEL processes. To verify this, we can launch the flow trace (click on the Launch Flow Trace button) in the Enterprise Manager console, and we will see that the two bookstore BPEL processes have been invoked, as shown:
An even more interesting view is the flow view, which also shows that both bookstore services have been invoked. Click on BookWarehousingBPEL
to open up the audit trail: