BPEL structured activities: Pick
Using BPEL Pick activity, you can specify which process would be executed according to the received event. Event could be a message event or an alarm event. For each event, we can specify a set of activities to be performed.
Objective: creating a BPEL process to run either operation sayHello or sayGoodbye according to a received message.
Tools: Eclipse 3.6, BPEL Designer 0.5.0 Plugin, Tomcat 7.0.53, ODE 1.3.5
BPEL's Pick activity
Create a new BPEL project named “BPEL_Pick” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name as BPEL_Pick and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
Create a new BPEL process file named PickSample by right clicking on the BPEL_Pick/bpelContent folder, select New→Others→BPEL 2.0→New BPEL Process File. Click Next. Fill in BPEL Process Name the string PickSample, and in the Namespace the string http://pick.bpel.tps. click Next.
Select the Template as
Synchronous BPEL Process and modify the Service Address as
http://localhost:8080/ode/processes/PickSample (suppose that your Tomcat environment is running on port 8080). Click
Finish.
Open the PickSampleArtifacts.wsdl file in your project. Right click on the PickSamplePort. Select show properties and make sure that the Address is http://localhost:8080/ode/processes/PickSample. Right click on the PickSample Port Type. Select Add Operation.
Rename the new operation as
sayGoodbye . Rename the existing operation from
process to
sayHello.
Open the
Outline→Bindings→PickSampleBinding. In the
Properties view. Click
Generate Binding Content... Keep default declaration, select
Overwrite existing binding Information.
Finish.
Open the PickSample.pbel file to design the process. Click and drag the Pick activity from the Palette to the process before the receiveInput activity.
In the Details tab of the Pick activity, select the option Create a new Process instance if one does not already exist.
Remove the
receiveInput activity and move the
replyOutput activity to the
OnMessage event, inside the Pick. Click and drag an
Assign activity to the process,
before the replyOutput. A Sequence is automatically created.
Click on the
OnMessage activity. In the
Details tab, select the operation
sayHello.
Right click on the
Pick activity. Select
Add OnMessage. In the
Details tab, select the operation sayGoodbye. Add an
Assign activity and a
Reply activity to the sayGoodbye branch.
Click on the
Reply activity of the sayGoodbye branch, in the
Details tab, assign the
PickSample→sayGoodbye→sayGoodbyeResponse→parameters→out to the
clientResponse variable.
The same way with the replyOutput activity, assign PickSample→sayHello→PickSampleResponseMessage→payload→result to the output variable.
Click on the
Assign activity, select
Details→New. Assign the expression
concat(“Hello ”,$input.payload/tns:input) to the
output→payload→result variable. A pop-up dialog appears asking you about the variable initiation. Select
Yes.
The same way, at the Assign1 activity, assign the expression concat(“Goodbye ”,$clientRequest.parameters/tns:in) to the clientResponse→parameters→out variable.
It's now finish the design part. Verify that there is no error in the dessign. We move to the service declaration and registration.
Right click on the BPEL_Pick/bpelContent folder, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. Click Next. Verify the BPEL Project name as /BPEL_Pick/bpelContent. Click Finish.
Open the deploy.xml file. And select the Associated port with the Partner Link client is PickSamplePort.
Save file and open the Server view, right click on the Ode v1.x Server at localhost, select Add and Remove Projects. Select the BPEL_Pick in the Available projects box and click Add. Then, click Finish.
Start the ODE server and use the Eclipse's
Web Services Explorer to test our application. You will see two operations
sayHello and
sayGoodbye that you can select to use. Depending on the operation you select, BPEL will execute the respective process.
Done.
Exercices
Create a simple BPEL process to execute one of the operations add(+) and subtract(-) two integers using Pick activity.
Back to top