Sunday, 8 September 2013

SIMPLE JAVA EMBEDDING IN BPEL SERVICES

This tutorial explains how to embed java program in Bpel service.

STEP 1 :  Go to jdeveloper -> Create a new project

STEP 2 : Drag a Java embedding service into Bpel service between receive and reply activity
                as shown below.Also  drag and drop two assign activities as shown below.


     

STEP 3 : Double click on java embedding activity and write lines of code you wish.Below are lines I wrote to concatenate two strings.

String read1=(String)getVariableData("Variable1_input");      
String read2=(String)getVariableData("Variable1_input1");      

      
try     
{     
      
System.out.println("Hello");   
String read3 = read1.concat(read2); 
setVariableData("Variable1_output",read3);  

     
}     
     
catch (Exception e)       
     
{     
     
System.out.println("Error"); 
 
}


Please note the above code is just like we write in java but bpel will not throw any error on failed compilation.Only error " scac 50012" will come.So unless you are good in compiling code its tough to write logical programs.


STEP 5 : Double click on assign activity to map outpariable of java with output variable of bpel variable.

STEP 6: Compile Deploy and test your services.


Happy Programming.............







No comments:

Post a Comment