Friday, July 10, 2020

Java Callout in OSB 12c

In this post, I will show you how to create a simple java callout in OSB that adds up two numbers.

1. Create a Service bus project with the name 'JavaCallout'.




Click on Finish.

2. Now create a proxy service.




Check the checkbox 'Generate Pipeline'. Click on Next.




Select Service Type as 'Any XML' and click Next and then Finish.

3. Double click on the pipeline. Drag and drop a pipeline pair.




Now, drag and drop a Java Callout activity in the request pipeline. 




Select the jar file in the Method value. In my case, I'm selecting a jar file which contains the java class to add two numbers. The code of the Java class is as below for your reference:




Now, give the Expression for the int variables under Arguments. As I used the type of both variables as int, it is showing me as int in Arguments section.




Give the values as below:

For the first int variable: xs:int($body/*:result/*:Num1)
For the second int variable: xs:int($body/*:result/*:Num2)
Return variable: Result

4. Now, drag and drop a Replace activity in the response pipeline.




Select the values as below:

Location: body
XPath value: . ('.' represents the current node)
Value: $Result
Replace option: Replace node contents




Here, $Result is the variable that we assigned output to in Java Callout.

6. We've done with all the steps. Now, deploy the project into OSB server and click on the Proxy service or pipeline to test the service. Give the input in XML as below:

<result>
<Num1>18</Num1>
<Num2>45</Num2>
</result>

Of course, you can give any numbers that you want. Cheers!!

Thursday, July 9, 2020

Hello World Demo in Oracle OSB

This post shows how to create a simple hello world demo using service bus project in OSB Application.

1. Create a new service bus project in service bus application. If the application is not created, create a new OSB application (Click New>Service bus application).
Click on New>From Gallery>Service bus Project.



Give a name to the Project and click on Finish.


2. Drag and drop a pipeline from the Components section. Change the name if you want to and click Next.



 In the next screen, select WSDL and click on 'Create a WSDL' icon to create one.



3. In the WSDL screen, select the Interface type as Synchronous Interface as below.


Now, click on the '+' icon under Input.


Change the Part Name if you want to change and click on the magnifier icon in URL field to select the type. You can also choose this using xsd file but I've given it manually without creating the schema to keep it simple.


Expand XML Schema Simple Types and select string as type. Then Click OK. Do the same for Output variable and click OK in the WSDL screen.


4. Check 'the checkbox Expose as a Proxy Service' and then click Finish.



Your composite would look like this.




5. Double click on the Pipeline. You'll see a pipeline like below.



Drag and drop a Pipeline Pair from the Components. Add a Replace activity in the response pipeline as below.


Click on the Replace and add values as below.

location: "'body
XPath Expression: . ("." represents curent node)
Value: concat('Hello ', $body/hel:string)
Replace option: Replace node contents.





6. Now that we have done with creating a sample hello world project, save the project and deploy the project to the OSB server. For deployment, right click on the project, select deploy option.



Select osb server and and Finish.

Now go to service bus console page and click on the pipeline or proxy service of the project to test it.

Cheers!!



Featured Posts

Sample Real Time Assignment in Oracle SOA