Sunday, March 10, 2013

Sometime Oracle Service Bus is not sufficient to perform some of the tasks, to do that tasks we need to use Java code. Oracle Service Bus has provided “Java Callout” feature, by using it we can invoke Java code from OSB.

In this Post, I will explain a very basic Java Callout example in Oracle Service Bus.

Java Callout
Java Callout
Follow below steps to use Java Callout activity in Oracle Service Bus.

<!--[if !supportLists]-->     1.)    <!--[endif]-->Create one static method inside class and package it to a jar file. Use the following guidelines for the Java Callout method:

  • The method must be static.

      Only the following Java types are supported for input parameters:

  • boolean, byte, char, double, float, int, long, short and arrays of these types
  • java.lang.[Boolean | Byte | Character | Double | Float | Integer | Long | Short | String] and arrays of these types
  •  java.math.[BigInteger | BigDecimal] and arrays of these types
  •  org.apache.xmlbeans.XmlObject and arrays of this type

 Only the following Java types are supported for method return:
  • All types supported for input parameters except their array equivalent
  •  void
Java Class
Java Class

2.)  Create a new OSB project and import WSDL and XSD of End service that we want to invoke from it.

3.)  Create Business Service from above imported WSDL file and similarly create Proxy Service either from that WSDL file or from Business Service.

4.)  Now Import the Jar file into new OSB project. To import jar file go to Create Resources --> Select Resource Type --> Select “Jar” under Utility section.

5.)  Now Go to Proxy Service message flow and add “Java Callout” activity.

Add Java Callout Activity
Message Flow- Java Callout Activity

6.)  Click on “Method” link and it will open a Pop-Up window.
Select Java Method
Java Method
7.) Select imported jar file.

Select Imported Jar file
Jar File
8.)  Expand Java class and choose the required method.

Choose Java Method
Choose Java Method

For small business website solutions, we recommend website solutions from AJIBOYE.

9.)  Now we need to specify Input and output parameters.

Specify Input and Output parameters
Specify Input/Output

Expression: link to the XQuery/XSLT Expression Editor, where you can create an expression to retrieve a value for the argument

Return Parameter as Reference: This option makes the return value of a Java Callout invocation a <java-content ref="jcid"> reference element regardless of its actual type, where jcid is the key to the object in the pipeline object repository. In the Result value field, enter the name of the variable to contain the java-content reference. This option lets you work with a referenced object in the message flow in addition to the pipeline XML for providing pass through, performing message enrichment with Java Callout and inline actions, or performing message transformation between Java and non-Java transports.

Result Type: The variable to which the result is assigned. The label for the field indicates the data type of the result. If the result is a byte array (the only possible array returned), the binary-content XML element is returned.

Service Account: An optional Service Account, which can be specified if there is a security context for this Java method. Click Browse to select a service account. In the case of fixed and mapped service accounts, the userid/password from the service account is authenticated in the local system and the security context propagated to the Java Callout. In the case of passthru, the security context is propagated to the Java Callout. This context is the message level context if defined (with WS-Security). Otherwise, it is the transport level context.

10.)  In Expression  provide Input parameter value.

Input Parameter

11.)  Provide Result variable name.

Result Variable
Result Variable

12.) Assign/Replace response from Java Callout to End service Input.

13.) The Response from Java Callout is passed to End Service.

Java Response to End Service Request
Java Response to End Service Request
14.) Test the proxy service.

Test Console
Test Console

Test Result
Test Result


  1. Hi Vivek ji,

    I'm follower of your blog all arevery useful posts, i got a doubt at "add child process WSDL and Schema file in Master process and create Child process partner link." how to do it i did not get , would you please explain the example in detail in your next post, it's a request after posting please notify me.

    Thank you..