Switch Condition in BPEL 1.1
Aim of the program
Create a process that takes in PO amount to find out if approval is required using Switch Condition in BPEL 1.1
- The amount is less than 1000, it returns ‘No Approval Required’
- The amount is between 1000 and 10000, it returns ‘Approval Required’
- The amount is more than 10000, it returns ‘Cannot be approved’
Start by creating a composite containing a synchronous BPEL process.
Modify the BPELProcess1.xsd to modify the names of input and output, to better mimic real world scenario
Drag a switch activity in the Bpel process.
Expand the Switch and click on the expression builder
The expression builder comes up. Select the client input, surround it with number() function and add the condition.
The Condition Expression window is now populated. You can also give a name to this branch, say LessThan1000
Add another case to the switch statement, for the scenario when PO amount is between more than 10,000
Now add the relevant expression.
number(bpws:getVariableData(‘inputVariable’,’payload’,’/client:process/client:POAmount’))>10000. The condition looks as follows.
Add three assign activities, one in each of the cases of the Switch activity and one in the otherwise branch. Give appropriate names and add copy operations to assign ‘No Approval Required’, ‘Requires Approval’ and ‘Cannot be approved’ to the result part of outputVariable.
The final process looks like this
Deploy and test. Give inputs like 500, 1500 and 15000 to see the different branches in action.