Oracle® BPEL Process Manager Order Booking Tutorial
10g Release 2 (10.1.2) B15813-02 |
|
Previous |
Next |
This chapter of the tutorial describes how to build conditional branching logic.
This chapter contains the following topics:
This phase of the tutorial adds to the OrderBooking process you designed in Chapter 4, "Adding Parallel Flow". Ensure that you have successfully completed that phase before performing this one. In this phase of the tutorial, you build conditional branching logic to select the lowest priced supplier. You perform the following key tasks:
Design conditional branching logic to select the lower price from the two services (Rapid Distributors and Select Manufacturing).
Deploy the BPEL process.
Run the deployed BPEL process from Oracle BPEL Console by completing and submitting an order form that is sent in parallel to the Rapid Distributors service and the Select Manufacturing service.
Access the Rapid Distributors URL to manually submit a supplier price.
Review the lower of the two supplier prices returned from the Rapid Distributors service and the Select Manufacturing service.
This section contains the following tasks:
Creating an Assign Activity Under the Case Block for the Rapid Distributors Service
Creating an Assign Activity Under the Otherwise Block for the Select Manufacturing Service
Validating, Compiling, and Deploying the Order Booking Process
Summary: To compare the two offers and make decisions based on that comparison, the BPEL flow requires a Switch activity. A Switch activity includes two branches: <case> and <otherwise>. The first branch is executed if a defined condition (inside the <case> branch) is met. If it is not met, the <otherwise> branch is executed. |
Drag and drop a Switch activity from the Component Palette section to below the GetPriceQuote Flow activity.
Double-click the question mark for the Switch activity to display the Switch window.
Enter SelectSupplier in the Name field.
Click OK.
Double-click <case> to display the Switch Case window.
Enter the following expression in the Name field:
Is the Rapid Distributors price less than the Select Manufacturing price?
Press Ctrl and then the space bar in the Expression field to display a list for selecting (double-clicking) the following syntax. Edit as necessary. As you enter information, a trailing slash can appear. This means you are being prompted for additional information. Either enter additional information, or press the Esc key and delete the trailing slash to complete the input of information.
bpws:getVariableData('receiveRD_onResult_InputVariable','payload','/ns1:SupplierInfo/ns1:SupplierPrice') < bpws:getVariableData('receiveSM_onResult_InputVariable','payload','/ns1:SupplierInfo/ns1:SupplierPrice')
Click OK.
Select Save from the File main menu.
Summary: This Assign activity assigns the Rapid Distributors supplier to the supplier part of the input purchase order variable. |
Drag and drop an Assign activity from the Component Palette section under the <case> section of the SelectSupplier Switch activity.
Double-click the Assign activity.
Click the General tab.
Enter SelectRapidDistributors in the Name field.
Click Apply.
Click the Copy Rules tab.
Click Create to display the Create Copy Rule window.
Field | Value |
---|---|
From |
|
|
Expression |
|
concat(bpws:getVariableData('inputVariable','payload','/ns1:PurchaseOrder/ns1:OrderInfo/ns1:OrderComments'), ' - Selected: Rapid Distributors')
Note: Press Ctrl and then the space bar to display a list for selecting (double-clicking) this syntax. The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. Remove any trailing forward slashes (/) that appear at the end. |
To |
|
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments |
Click OK to close the Create Copy Rule window.
Click the Copy Rules tab.
Click Create to display the Create Copy Rule window.
Enter the following details to create a second statement:
Field | Value |
---|---|
From |
|
|
Variable |
|
Expand and select Variables > receiveRD_onResult_InputVariable > payload > ns1:SupplierInfo
Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. |
To |
|
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:SupplierInfo |
Click OK to close the Create Copy Rule window and the Assign window.
Select Save from the File main menu.
Summary: This Assign activity assigns the Select Manufacturing supplier to the supplier part of the input purchase order variable. |
Drag and drop an Assign activity from the Component Palette section under the <otherwise> section of the SelectSupplier Switch activity.
Double-click the Assign activity.
Click the General tab.
Enter SelectManufacturing in the Name field.
Click Apply.
Click the Copy Rules tab.
Click Create to display the Create Copy Rule window.
Enter the following details:
Field | Value |
---|---|
From |
|
|
Expression |
|
concat(bpws:getVariableData('inputVariable','payload','/ns1:PurchaseOrder/ns1:OrderInfo/ns1:OrderComments'), ' - Selected: SelectManufacturing')
Note: Press Ctrl and then the space bar to display a list for selecting (double-clicking) this syntax. The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. Remove any trailing forward slashes (/) that appear at the end. |
To |
|
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments |
Click OK to close the Create Copy Rule window.
Click the Copy Rules tab.
Click Create to display the Create Copy Rule window.
Enter the following details to create a second statement:
Field | Value |
---|---|
From |
|
|
Variable |
|
Expand and select Variables > receiveSM_onResult_InputVariable > payload > ns1:SupplierInfo
Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. |
To |
|
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:SupplierInfo |
Click OK to close the Create Copy Rule window and the Assign window.
When complete, the designer window looks as follows:
Click the - sign next to the diamond to close the Switch activity.
Select Save from the File main menu.
Go to the Applications Navigator section.
Right-click OrderBooking.
Increment the version number of the project when prompted and click OK (for example, enter 1.3).
This compiles the BPEL process. Review the bottom of the window for any errors. If there are no errors, deployment was successful. If deployment was unsuccessful, see Step 5.
Log into Oracle BPEL Console by selecting Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager 10.1.2 > BPEL Console (or refresh the page if it is already open).
The Dashboard tab of Oracle BPEL Console appears.
Start the OrderBooking instance version you increased in Step 5 in one of the following ways:
Open the CreateOrderBookingUI application at http://localhost:9700/CreateOrderBookingUI
and provide inputs to initiate a process.
Click OrderBooking in the Deployed BPEL Processes list and enter details in all fields of the HTML Form and click Post XML Message.
Click OrderBooking in the Deployed BPEL Processes list and select XML Source from the Initiating a test instance list. Use a text editor to copy and paste the contents of the OrderBookingPO_1.xml
file into the field that appears. Click Post XML Message.
The BPEL Processes tab displays a message similar to the following:
Test Instance Initiated
Complete the manual price quote task for SelectManufacturing by using the graphical user interface JSP page, as described in Step 10.
Return to Oracle BPEL Console.
Click the Instances tab at the top.
Verify that the OrderBooking, CreditRatingService, TaskManager, SelectManufacturing, and RapidDistributors instances were created. All should appear in the Instance list. The Last Modified list displays the times at which they were created.
Click the instances.
Click the Audit link to follow the instance execution process.
Click the More... link for each sequence to view the activity details.
Verify the results of conditional branching, the value of the price quote, and the execution path of the condition logic. (Similar instance management can also be obtained in a graphical fashion under the Flow link.)
You have now built conditional branching logic to select the lowest priced supplier. You performed the following key tasks:
Designed conditional branching logic to select the lower price from the two services (Rapid Distributors and Select Manufacturing).
Deployed the BPEL process.
Ran the deployed BPEL process from Oracle BPEL Console by completing and submitting an order form that was sent in parallel to the Rapid Distributors service and the Select Manufacturing service.
Accessed the Rapid Distributors URL to manually submit a supplier price.
Reviewed the lower of the two supplier prices returned from the Rapid Distributors service and the Select Manufacturing service. After the two supplier services (Rapid Distributors and Select Manufacturing) returned with a price quote, a conditional branching decision was taken to select the lowest priced supplier.