1. While Activity in BPEL
While activity in bpel is just like a simple while activity in c++/JAVA .SO its general algorithm
is perform certain task till the condition is valid.We will try to implement it practically in our
example to understand the use case of while activity.
Our logic here is we will provide an input value which will be int and then we will call a
partner link where in we will be incrementing the value of this input variable.Our while loop
will check how many times we have to invoke the service.
Ok so first of all we will design a BPEL process to increment the value of input data.
First of all create an application and then create a BPEL process .Give this bpel process
some logical name like Called because it will be called from another bpel process.Make this
bpel process synchronous process becasue we want to pass the output value to the caller
bpel process.
Now drag and drop an assign activity between the receive input and reply output.
2. Now double click on the assign acitivity and on the drop down box select a copy operation.
In the from choose the type as expression and provide the value
bpws:getVariableData('inputVariable','payload','/client:CalledProcessRequest/client:input')+
1
It can be created from the xpath building expression window double click on the input
variable in the BPEL variables table and just add 1 to it as shown below
3. Now assign this to the output variable so the window should appear like this
so your process is complete.Now deploy process and check that process in the BPEL
console.
Just provide an input as 2 and you will get an output as 3.So we are done with one process
now we will create another bpel process where in we will use our while concept.
Create one more bpel process and call it as Caller.Make this process as asynchronous
process.
Drag and drop a while activity in between the input and callback as below
4. Expand it and drag and drop a invoke activity in it as below.
Now select services from the component pallete and drag and drop a partnerlink in the
services space of the bpel designer.
5. a window will come up like this.
Provide the WSDL for the called process.YOu can copy it from the BPEL console.Just
select the Called bpel process in dashboard and switch to wsdl you will get the wsdl file
there.It will be of format
http://host:port/orabpel/default/Called/1.0/Called?wsdl
Provide it and choose the partner role as provider because the partner you are calling is the
provider for the service.You role can be left untouched.
Now just automatically create the input and output variable in invoke wizard
6. now drag and drop a assign acctivity and put one in between receive input and while loop
and other after the invoke in the while loop.
So your bpel process should now look like this
Now double click the first assign activity and create a copy operataion.
7. Assign the input vatiable to the input variable of the invoke activity
Double click on the second assign activity after the invoke and assign the result of the
invoke activity to the input of the invoke activity.
create one more copy operation and assign the output of the invoke to the intial input
variable.this we are doing as in our while loop we will be using a logic to compare with the
input value that we have passed.We can creat our own varialbe and compare it it depends
upon your own logic how you desing it i have chosen to assign it to the initial input variable.
8. Now we will specify the while condition
Click on condition expression and choose the expression builder to log in to the following
wizard
there in double click the input varialbe and provide a condition that it should be less than 5
as below
now you are done with the desingning of bpel process go ahead and deploy this process.
Invoke it and provide an input as 3 so that it will be invoking the partnerlink twice.So in bpel
9. console if you will open the flow you will get output like this
In order to clear the logic i will just write its algorithm
int i=3
while(i<5){
i++}
we are working on this simple logic.Initialized process with value 3 enter while loop and
invoke the partnerlink.it will increment the value to 4,it wil check the condition it is not valid
so again it will call the partner link and valur will be incremented.