We use Service Callout option inside Oracle Service Bus to call any service inside message flow to get the required data. In this post, I will show you how to use Service Callout activity in Oracle Service Bus and pass the response from callout service to next service.
To show how Service Callout works in Oracle Service Bus, we have created two services. First service (Customer Name Service) will return Customer Name as response message when we pass Customer Id as request message and second service (Target Service) accept both Customer Id and Customer name as request message.
We use Service Callout option to call first service (Customer Name) and pass Customer Id as input to it and it will give us Customer Name as response message. We will use service callout response message and add it to the proxy service input and pass it to target service which accepts both Customer Id and Customer Name.
First Create a New OSB Project and add proxy, business and resources folders to it.
Load first & second service WSDL and XSD files to newly created project under resources folder.
Now we create Business service using first service WSDL file. We later use this business service in Service Callout activity.
Accept defaults and save your business service.
Now Create Business service using second service WSDL. This will be our target service means we will route the final message to this service.
Now create a proxy service using first service WSDL file.
Now we will add required activities or logic in the Proxy service message to do Service Callout and pass service callout response to another service.
Go to Message Flow of proxy service and click on “Add Route” to add route Node. Rename the route activity.
Click on “Edit Route” and then click on “Routing” to add routing inside message flow.
Choose “Target Business Service” created above as this is our target service and we need to pass final complete message to this service.
Choose service operation.
In the Request Action, add “Service Callout” activity to call first service (Customer Name service).
Choose service operation and define request and response messages.
Now we need to assign request message to Service Callout request message. To do that first we need to create two variables inside message flow with the name “CustomerNameReqMsg” & “CustomerNameRespMsg”.
Refer to my previous post to see how to create custom variables in Oracle Service Bus.
For CustomerNameReqMsg assignment , add Replace activity.
In the replace acitivity pass the Customer Id from proxy Request message to CustomerNameReqMsg variable.
Click on “Replace Node Content” as we need to pass the content to CustomerNameReqMsg variable.
If you will save your message flow and test the proxy service till here, you will see that you are able to call Customer name service using Service Callout.
Now in the next step we will use Service callout response message, add it to Proxy request message and pass the message to target service.
To do this add “Replace” activity. Take data from CustomerNameRespMsg variable and add it to body variable which is proxy service message.
Save your flow and activate the session.
Download Sample Code