Using While Loop in SOA BPEL
Objective of this Post:
In this post I will be focusing on the Looping construct “While” which is most commonly used by most programming language. Here we are also going to use simple Java Embedding Activity which allows us to write and execute java code from with in the SOA composite.
Prerequisite: You must have a simple composite like HelloWorldSOAComposite.
Lets Achieve this:
We need to follow the steps below to achieve our objective.
- Open the bpel file in Jdeveloper
- Add new variable “count” by clicking on from the top bar.This will open the following window.
- Click on Variables and then click on icon. This will launch another window as follows:
- Enter variable name as count select type as int
- click on OK. This will create a global variable count with xsd type int.
- Click on close.Now double click on assign Activity.Here we will assign the value to count variable as 5.
- Click on OK.
- Click on OK. Now from the component palette drag drop while activity after Assign1 Activity.
- Double click on While activity
- For specifying condition click on expression.This will launch following window. Double click on count variable. and then from the Functions select logical function greater and then add zero to it. “bpws:getVariableData(‘count’) > 0”
- Click on OK
- Click on Apply and OK.Now From the component Palette search box enter “java” and hit search.
- Drag drop this activity inside While loop .
- Now double click on Java embedding activity. In this activity you can write your java code provided all the imports are done OR fully qualified class names are used. As of now we will just use System.out.println(“Hello, World”);
- Just copy paste the System.out.println(“Hello, World”); and click OK.
- Add another Assign activity inside the loop to decrement counter by 1.
- Double click on assign and set the expression for counter as follows:
- Click on OK.
- Click on OK and Deploy the composite similar to the steps mentioned in Deployment section of HelloWorldSOAComposite. Post.
- To test the functionality go to EM console and click on your composite. Then click on Test. Check SOA server console for the output.
Reference Links:
Comments
Post a Comment