Step 1:- Write Shell Script For addition of two number.
<?xml version= '1.0' encoding= 'UTF-8' ?>
Step 2:- Create XSD which will contain two numbers.
<?xml version= '1.0' encoding= 'UTF-8' ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.oracle.com/ns/Numeric"
xmlns:num="http://xmlns.oracle.com/ns/Numeric" attributeFormDefault="qualified" elementFormDefault="qualified">
<element name="Numeric" type="num:NumericType"/>
<complexType name="NumericType">
<sequence>
<element name="Num1" type="int"/>
<element name="Num2" type="int"/>
</sequence>
</complexType>
</schema>
Step 3:-Write a Java code to call shell script along with passing variable to script. Below code is written to open the script created in cygwin.
package com.test;
import java.io.*;
public class MyTest1 {
public String ShellScript(int i, int j) throws IOException
{
String Var=null;
try{
Process P;
System.out.println(i);
System.out.println(j);
String strParam = "D:\\cygwin\\bin\\bash -c '/cygdrive/d/testShell/SumOfTwoNumber.sh "
+ i +" + "+ j+" '";
P = Runtime.getRuntime().exec(strParam);
System.out.println("here " + strParam);
BufferedReader br = new BufferedReader(new InputStreamReader(P.getInputStream()));
String line=null;
while ( (line = br.readLine()) != null){
System.out.println("Output" + ">" + line);
Var=line;
}
System.out.println(line);
System.out.println("Output of Var:-" +Var);
int wait = P.waitFor();
System.out.println("exit code: "+wait);
}
catch (InterruptedException ie)
{
System.out.println("exception caught");
}
catch (Throwable t)
{
t.printStackTrace();
}
return Var;
}
For Script available in Bash or Corn Shell then need to modify line.
String strParam = "bin\bash -c \SumOfTwoNumber.sh + i +" + "+ j+" ";
String strParam ="bin\ksh -c \SumOfTwoNumber.sh + i +" + "+ j+" ";
Step4:- Create BPEL process to contain java embeed.
Modify BPEL source code to containg following below class
<bpelx:exec import="YourFullyQualifiedClassName(example com.oracle.shellscript)"/>
Java Embeed will contain following below code
MyTest1 pocob = new MyTest1();
try{
addAuditTrailEntry("Started From This Place");
String i = ((oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/ns1:Numeric/ns1:Num1")).getFirstChild().getNodeValue();
int k = Integer.parseInt(i);
addAuditTrailEntry("k Variable " +k);
String j = ((oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/ns1:Numeric/ns1:Num2")).getFirstChild().getNodeValue();
int n = Integer.parseInt(j);
addAuditTrailEntry("n Variable " +n);
addAuditTrailEntry("Before Variable");
String greetings = pocob.ShellScript(k,n);
addAuditTrailEntry("After Variable");
addAuditTrailEntry("Value:- " +greetings);
setVariableData("Var1",greetings); //Var1 is a variable created in BPEL process to contain result
addAuditTrailEntry("After Assignment");
} catch(Exception io){
addAuditTrailEntry("Exception occured:"+io.getMessage());
javax.xml.namespace.QName qName=new javax.xml.namespace.QName("http://schemas.oracle.com/bpel/extension","remoteFault");
com.oracle.bpel.client.BPELFault bpelFault=new com.oracle.bpel.client.BPELFault(qName);
throw bpelFault;
}
finally{
pocob=null;
}
addAuditTrailEntry("Exception occured:"+io.getMessage());
javax.xml.namespace.QName qName=new javax.xml.namespace.QName("http://schemas.oracle.com/bpel/extension","remoteFault");
com.oracle.bpel.client.BPELFault bpelFault=new com.oracle.bpel.client.BPELFault(qName);
throw bpelFault;
}
finally{
pocob=null;
}
Add following libraries in classpath.
Assign Var1 Variable to BPEL output variable.
Enjoy the testing.
Nice article.Thank you so much for sharing this excellent information..Oracle SOA Online Training can reduce your costs and middleware complexity better than any other solution. Finally, it can help you to achieve the best total value of opportunity.
ReplyDeleteIt really works for me. Thank you.
ReplyDelete
ReplyDeleteThanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle SOA Interview Questions and Answers
. Actually, I was looking for the same information on internet for
Oracle SOA Training and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more about Oracle SOA Tutorial also.
ReplyDeleteThanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle SOA Interview Questions and Answers
. Actually, I was looking for the same information on internet for
Oracle SOA Training and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more about Oracle SOA Tutorial also.
Fantastic article post. Really thank you! Awesome.
ReplyDeleteoracle bpm training
angular js training
sql server dba training
oracle golden gate training
Nice blog.Thanks for sharing
ReplyDeleteOSB Online Course
Online OSB Training