Prerequisite: For understanding this you must have some basic knowledge on SOA as this post involves using SOA to make it more clear to understand.
Well, Service Callout in OSB is similar to Invoke activity in SOA. We use Invoke activity in SOA to trigger external services like (WS Service, DB Service, JMS Service, FTP Service etc). Similarly we use Service Callout in OSB to trigger external services.
Similarities & differences b/w Invoke & Service Callout: Both used to trigger external services, but Invoke can be used for both Synchronous& Asynchronous external services (i.e the calling external service may or may not give the response). But Service Callout is used only to trigger Synchronous external services. To trigger oneway services there is another component in OSB which is ‘Push’ which also works same as Service Callout, only difference is Push is used for triggering Oneway external services and Service Callout is used for triggering Synchronous external services. Invoke activity will be having ‘Input Variable’ and ‘Output variable’ and similarly Service Callout will also has ‘Request Variable’ & ‘Response Variable’.
Let’s take a simple example and discuss about why and where we use Service Callout in OSB. I’ve a an external service asynchronous service ‘EmployeeInfo’ which accepts EmployeeId, EmployeeName as inputs.
- So in OSB first we have to import Resources (WSDL, XSD) for that external WSDL service. Then we have to create Business Service calling the ‘EmployeeInfo’ WSDL.
- Create a proxy service based out of Business Service created earlier.
- Now we have to pass ‘EmployeeId’, ‘EmployeeName’ as inputs the proxy service which will pass the same as inputs to the business service. But let’s make a requirement like we pass only ‘EmployeeId’ as input to the proxy service then in the Message Flow we have to call another external service ‘EmployeeName’ wsdl, passing ‘EmployeeId’ to get the respective ‘EmployeeName’ and then pass this retrieved ‘EmployeeName’ along with ‘EmployeeId’ to the ‘EmployeeInfo’ wsdl.
- So we have to create another Business Service calling ‘EmployeeName’ wsdl.
- From the MessageFlow using Service Callout call the ‘EmployeeName’ wsdl. While calling that service pass the ‘EmployeeInfo->EmployeeId’ to the ‘EmployeeName Request variable’ using Assign activity.
- Get the response from ‘ EmployeeName Response variable’ and replace it on ‘EmployeeInfo->EmpName’ using Replace activity. This concept is called Message Enrichment.
This is how and why Service Callout is used in OSB. Find below few screnshots for your reference.
The below screen explains about service callout variables (similar to Invoke activity input, output variables)
Note: In all the below screens please assume Customer as Employee.
Below screen explains about how we assign ‘EmployeeInfo->EmployeeId’ to ‘EmployeeName request variable’ with the help of Assign.
Below screen explains about how we replace the EmployeeInfo payload, ‘EmployeeInfoBS->EmployeeName input field’ to ‘EmployeeNameBS response variable’ with the help of Replace.
To make the above example work we need two SOA services ‘EmployeeInfo’ (Asynchronous) and ‘EmployeeName’ (synchronous) to be created and deployed on server. Which then have to be used in OSB project for creating business services.
Find below screens for SOA BPEL for EmployeeInfo’ (Asynchronous)
Find below screens for SOA BPEL for ‘EmployeeName’ (synchronous).
Hope this post helps you to understand concept of Service Callout in OSB.