Optimizing Integration: Retrieving and Displaying Multiple Values using Java Methods in OSB 12C


In OSB, while using the JAVA Callout function, we often face a limitation where if a Java program returns a single value, we can assign it to a result set in OSB and display it in the payload. However, if the Java program returns multiple values, it becomes challenging to assign them to a result set in OSB. In such cases, we need to create an XML format for the payload within the Java program itself to handle the multiple return values.

To achieve the above objective, we first need to create a Java file and then generate a JAR file based on it.


Generate the JAR based on below JAVA program. Generate JAR File



package javamultixmlprj; import org.apache.xmlbeans.XmlObject; public class CustJavaMultiXML { public CustJavaMultiXML() { super(); } static XmlObject newObject; public static XmlObject CustomerAddress(int CustId) { String Name=""; String City=""; String Designation=""; if (CustId==1000) { Name="Pranay Tiwari"; City="Columbus"; Designation="Application Developer" ; } else { Name="Ralph Dmitri"; City="Chicago"; Designation="Enterprise Architect" ; } String xmlString = String.format("<Customer xmlns=\"http://www.xmlobject.test/xml\">\n" + "<Name>" + Name + "</Name>\n" + "<City>" + City + "</City>\n" + "<Designation>" + Designation + "</Designation>\n" + "</Customer>\n"); try { XmlObject object = XmlObject.Factory.parse(xmlString); return object; } catch (Exception e) { e.printStackTrace(); return newObject; } } }


Create Service Bus Application -> JavaMultiReturnAPP







Create Project --> JavaMultiReturnPRJ



Create below folder structure in the newly created project







































Copy the newly created JAR file to the JAR folder 









































Create an XSD file based on the Java method, taking into consideration that the Java program has one input parameter and returns one output parameter. The XSD file should include input and output elements, and a WSDL file can be generated from the XSD file

For generation of XSD and WSDL file refer to this article Generate XSD and WSDL





Now lets go to the proxyServices folder and create Proxy Service by selecting the newly created WSDL.






Click OK and Finish to create the Proxy Services 






Click on Pipeline and drop pipeline pair node 














Drop "Assign" Component onto the pipeline pair node to assign input value to variable.





Assign CustId as variable 







Now next step is to drop javacallout component onto request pipeline



select the JAR file and method name and assign input variable





Provide return variable as  "OutputResponse" 




Drop Replace component on the response pipeline and assign OutputResponse variable as shown in the figure












Now run the integration by passing cust id 1000 in the payload 


















































Comments

Popular posts from this blog

REST integration built-in OIC to read Large files with size more than 10MB

Basic Concepts of OAF (Oracle Applications FrameWork )