Adding Two Integers in Oracle Service Bus (OSB) 12c using Java Method Callout
Oracle Service Bus (OSB) offers extensive modularity, allowing for the integration of a diverse range of technologies. In this article, we will explore how to use Java methods in OSB with the objective of implementing a use case that involves adding two integers . We will achieve this by leveraging a Java callout, which will enhance the flexibility and functionality of our integration solution."
To get started, let's create a Java class and generate a JAR file from
package Addpkg;
public class AddInt {
public AddInt() {
super();
}
public static int addNum(int num1,int num2)
{
int num3=0;
num3=num1+num2;
return num3;
}
}
Now create JAR file of the above class by following this tutorial Generate JAR in JDEVELOPER
Once JAR file generated , now lets create Application in JDEVELOPER
1. Go to Jdeveloper --> Create Application
Provide Application Name
Once Application Created , Create a Project --> Service Bus Project
Provide project Name : AdditionJavaPRJ
Create folders in newly created project as shown in below screenshot
Now click on Schema , Create New --> Click XML Schema
Provide XML Schema name AdditionNum.xsd to create XSD
Add Number1 & Number2 as two input elements and Result as output element
Now schema definition has been created , next step is to create WSDL based out on these xsd.
Provide WSDL file name
Select Interface Type as Synchronous Interface and select Input and Output response as shown in the screenshot.
With above step , WSDL generation completed. If you still have doubt refer this link WSDL Generation in JDEVELOPER
"The next step is to add the JAR files to our recently created project folder. Copy the JAR files that were created in the above step into the 'JAR' folder of the project
Now let's create proxy services
Click on Proxyservices folder --> Click on New --> Proxy Service
Provide Proxy Service Name and add the WSDL file name
Select the recently created WSDL and Click on OK
Click Finish
Proxy Services Created
Click on Pipeline and add PipeLine Pair
Now select the JAR file along with the method
select the JAR file
select the Method Name and click on OK
Provide input parameters as shown in the below screenshot
provide variable name as Outputvar to capture the returning value from Java method.
Java call out activity completed , now we need to capture the response . Drop Replace component at Response pipeline
Location : body
value : $Outputvar
Replace option : Replace node contents
Comments
Post a Comment