- Developing SOA Applications with Oracle SOA Suite
- Using the BPEL Process Service Component
- Using Conditional Branching in a BPEL Process
- Defining Conditional Branching with the If or Switch Activity
- Defining Conditional Branching with the Switch Activity in BPEL 1.1
- How to Create a Switch Activity
How to Create a Switch Activity
To create a switch activity:
- In the Components window, expand BPEL Constructs.
- Drag a Switch activity into the designer, as shown in Figure 11-6.
The Switch activity has two switch case branches by default, each with a box for functional elements. If you want to add more branches, select the entire switch activity, right-click, and select Add Switch Case from the menu.
- In the first branch, double-click the condition box.
A dialog for entering a condition is displayed, as shown in Figure 11-7.
- In the Label field, enter a name for the condition branch. When complete, this name is displayed in Oracle BPEL Designer.
- In the Condition field, click the Expression Builder icon to access the Expression Builder dialog.
- Create your expression.
bpws:getVariableDate('loanOffer1','payload','/loanOffer/APR') > bpws:getVariableData('loanOffer2','payload','/loanOffer/APR')In this example, two loan offers from completing loan companies are stored in the global variables
loanOffer1andloanOffer2. Each loan offer variable contains the loan offer's APR. The BPEL flow must choose the loan with the lower APR. One of the following switch activities takes place:-
If
loanOffer1has the higher APR, then the first branch selectsloanOffer2by assigning theloanOffer2payload to theselectedLoanOfferpayload. -
If
loanOffer1does not have the lower APR thanloanOffer2, theotherwisecase assigns theloanOffer1payload to theselectedLoanOfferpayload.
-
- Click OK.
The expression is displayed. The value you entered in the Label field of the dialog becomes the name of the condition branch.
- Click OK.
- Add and configure additional activities as needed. Figure 11-8 provides details.


