OSB: Java Callout with XML input and output parameter

With the Oracle Service Bus (OSB) it is possible to extend the functionality by using java callouts.

Java callouts are static operations implemented in Java and packaged in a jar file. The jar file and all dependencies have to be included into the OSB project. Then it is possible to select the operation in the java callout node.

Basic types like int and String are supported for the parameters and the return value of the callout (the full list and a good tutorial is available at Simple Java Callout Example). But much more interesting, because in OSB everything is about XML processing, is to use XML snippets for parameter and return value.

First we create a proxy service with a java callout.

BLOG_OSB_JavaColloutXML_01

Then we implement the java class for the java callout.

The static method called by the OSB:

We need a method processing the input XmlObject and doing something with the containing elements:

For the return value we create a new XmlObject containing e single resultElement element. Inside this element the real return values are located.

 

After compiling this class to a jar file and adding the jar file, xmlbeans and stax-api to the OSB project we can select our implemented method inside the java callout.

BLOG_OSB_JavaColloutXML_02

Finally we can deploy the whole thing to OSB and test it with the debug window.

BLOG_OSB_JavaColloutXML_03

 

Bernhard Mähr @ OPITZ-CONSULTING published at http://thecattlecrew.wordpress.com/

Leave a Reply