Oracle OSB 12c: Service Callout and Routing Table example

In this article, we will explore the use of Service Callout & Routing Table nodes in OSB 12c

We will re-use the last article and modify business case requirements and then accordingly implement the solution using “Service Callout” & “Routing Table” nodes

Service Callout: This node helps to enrich the content before invoking the business service on the request thread (similarly on the response thread)

Key points of Service Callout node:

  • OSB makes a call to a service through a service callout action, the content of the message is constructed using the values of variables in the message context
  • Message content for outbound messages is handled differently depending upon the type of the target service
  • Used in real time request-response scenarios
  • Call a service in synchronous way [Blocking]
  • Being a synchronous call, the thread gets blocked until a response is returned from target service
  • Using Service Callout node in Proxy Service’s Message Flow –> can invoke business service or another proxy service

Routing Table: A routing table is a set of routes wrapped in a switch-style condition table. It is a short-hand construct that allows different routes to be selected based upon the results of a single XQuery expression

Business case requirement:

  • This is the same use case for Employee Loan process in an organization used in the last article with little modification
  • When an employee of the organization submit the request for a loan, it goes through various process to get it approved
  • Employee enters basic details like employee id, name, grade and loan amount requested in dollars and comments if any
  • Employee details are validated using Employee Validation service
  • Outcome of the validation service is either Yes or No
  • And this employee validation outcome needs to be set in the request before routing to the business service (from there to invoke an actual enterprise web service)
  • This time, we are going to route the service based on the loan amount (in dollars) at the Routing Table level (unlike conditional branch node in the last article)
  • If entered loan amount in dollars is less than or equal to 4 thousands ($4K), then it goes through the default loan approval process
  • Otherwise, if entered loan amount in dollars is greater than 4 thousands ($4K), then it goes to HR Manager for approval

00_OSB-12c_Service_Callout_and_Routing_Table_example_Problem_statement_in_figure

 

Assumptions:

    • There are three web services for Employee Loan Process up & running on the application server
    • This web services can be invoked only through OSB
    • Three web services are
      1. Default Loan approval service
      2. HR Manager Loan approval service
      3. Employee Detail Validation Service (for employee detail validation)
    • For demo purpose, we will copy the WSDL and Schema files and paste in our Service Bus project under “Resources” folder
      This web service roughly based on this article, go through this article to understand the underlying web services part
    • Download this web service project used in this demo example from download section (scroll to last)

 

Let’s get started with designing OSB modules for Service Callout & Routing Table example in Oracle JDeveloper 12c IDE

 




Step 1: Open New Project

File Menu –> New –> Project

1_OSB-12c_Service_Callout_and_Routing_Table_example_New_Project

 

Step 2: Select Service Bus Tier from available categories

Service Bus Tier –> Service Bus Project –> OK

This opens up wizard for New Service Bus Project

2_OSB-12c_Service_Callout_and_Routing_Table_example_New_Service_Bus_Project

Note: Comparing this wizard with the one we have created in this article, the major difference is “Service Bus Project” option is enabled since we have one Service Bus Application in the user/developer workspace (already created)

 

Step 3: Enter Project Name and its directory location for the new Service Bus Project

Leave the default values for demo; otherwise we can give more specific names in accordance with naming convention followed in the project

Project Name: ServiceCalloutAndRoutingTableSB

Click Finish

3_OSB-12c_Service_Callout_and_Routing_Table_example_New_Service_Bus_Project_name

New Service Bus project will be created with required artifacts

 

Step 4: Create required folders in accordance with project standards (naming conventions)

Generally, there should be

  • ProxyService folder to place/store/save the proxy services which ends with .proxy
  • BusinessService folder to place/store/save the business services which ends with .bix
  • Resources folder to store all other required artifacts like WSDL, Schema and transformations files

Now, we will create above listed folders

Right click on the Service Bus project –> New –> Folder…

Opens up a new wizard

4_OSB-12c_Service_Callout_and_Routing_Table_example_New_folder_create

Note: If you don’t find “folder” option directly, then click on “From Gallery” and from there choose folder option and continue with below next steps

 

Create Folder wizard –> enter folder name like, for example “BusinessService” for Business Service

Finally click OK –> to create folder

5_OSB-12c_Service_Callout_and_Routing_Table_example_New_folder_create_provide_name

 

Similarly, we can create “ProxyService” and “Resources” folders

After creating all three folders namely ProxyService, BusinessService and Resources, our project will look like below screenshot

Note: Also create “entities” & “wsdl” folders under “Resources” to store/keep Schema and WSDL files (separately)

6_OSB-12c_Service_Callout_and_Routing_Table_example_after_all_folder_create_step

 

Step 5: Enterprise Information System (EIS) or Exposed Web Services

As we discussed in the assumption section, there are three web services up & running at below URLs in the application servers

  1. http://localhost:8080/EmployeeLoanService/services/DefaultLoanApprovalService?wsdl
  2. http://localhost:8080/EmployeeLoanService/services/HRManagerLoanApprovalService?wsdl
  3. http://localhost:8080/EmployeeLoanService/services/ValidateEmployeeDetailService?wsdl

So we will copy Schema and WSDL files && paste it to the Resources folder as directed below

XML Schema –> under “entities” folder
WSDL –> under “wsdl” folder

7_OSB-12c_Service_Callout_and_Routing_Table_example_copying_entities_wsdl

Note: Make sure those three web services are running

 

Business Service

Step 6: Create Business Service to invoke the exposed Web Service

There are three Business Services

  • Default Loan Approval Service
  • HR Manager Loan Approval Service
  • Employee Validation Service

Drag and drop HTTP component from Technology palate to External Services lane (Business Service in 11g)

8_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_HTTP_component

Upon dropping, a new wizard pops up to enter the required details for Business Service or External Service

 

Step 6.a: Fill up the mandatory details for Business Service (i.e .bix file)

Service Name: DefaultLoanApprovalServiceBS (append BS to the business service as a naming standard)
Location: browse through “BusinessService” folder we created in earlier step
Transport: http (keep it as it is)

Click Next

9_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_6a

 

Step 6.b: Select “WSDL” from four available options

And browse to wsdl location by clicking first icon with green arrow mark pointing towards right hand side (i.e.; wsdl is placed under “Resources/wsdl” folder)

Choose “Application” and select correct WSDL we have stored for this project

Finally click OK and then click Next

10_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_6b

 

Step 6.c: In step 2 of Create Business Service wizard –> populates wsdl file with port after reading the WSDL file we have chosen in the previous step

Click Next

11_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_6c

 

Step 6.d: In step 3 of Create Business Service wizard –> populates the endpoint URI for the exposed web service to be invoked

Click Finish

12_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_6d

Similarly, we will create business service for second service i.e.; HR Manager Loan Approval Service

 

Step 7.a: Fill up the mandatory details for Business Service (i.e .bix file)

Service Name: HRManagerLoanApprovalServiceBS (append BS to the business service as a naming standard)
Location: browse through “BusinessService” folder we created in earlier step
Transport: http (keep it as it is)

Click Next

13_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_7a

 

Step 7.b: Select “WSDL” from four available options

And browse to wsdl location by clicking first icon with green arrow mark pointing towards right hand side (i.e.; wsdl is placed under “Resources/wsdl” folder)

Choose “Application” and select correct WSDL we have stored for this project

Finally click OK and then click Next

14_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_7b

 

Step 7.c: In step 2 of Create Business Service wizard –> populates wsdl file with port after reading the WSDL file we have chosen in the previous step

Click Next

15_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_7c

 

Step 7.d: In step 3 of Create Business Service wizard –> populates the endpoint URI for the exposed web service to be invoked

Click Finish

16_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_7d

Similarly, we will create business service for third service i.e.; Employee Validation Service

 

Step 8.a: Fill up the mandatory details for Business Service (i.e .bix file)

Service Name: EmployeeValidationServiceBS (append BS to the business service as a naming standard)
Location: browse through “BusinessService” folder we created in earlier step
Transport: http (keep it as it is)

Click Next

17_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_8a

 

Step 8.b: Select “WSDL” from four available options

And browse to wsdl location by clicking first icon with green arrow mark pointing towards right hand side (i.e.; wsdl is placed under “Resources/wsdl” folder)

Choose “Application” and select correct WSDL we have stored for this project

Finally click OK and then click Next

18_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_8b

 

Step 8.c: In step 2 of Create Business Service wizard –> populates wsdl file with port after reading the WSDL file we have chosen in the previous step

Click Next

19_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_8c

 

Step 8.d: In step 3 of Create Business Service wizard –> populates the endpoint URI for the exposed web service to be invoked

Click Finish

20_OSB-12c_Service_Callout_and_Routing_Table_example_HTTP_Business_Service_wizard_8d

Finally all three Business Services are created

 

Business Service is created on the External Services lane and this resides under “BusinessService” folder

21_OSB-12c_Service_Callout_and_Routing_Table_example_all_3_Business_Service_created

 

Proxy Service

Step 9: Create Proxy Service and add pipeline

Drag and drop HTTP component from Technology palate to Proxy Services

22_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_HTTP_component_to_proxy

Upon dropping, a new wizard pops up to enter the required details for Proxy Service

 

Step 10.a: Fill up the mandatory details for Proxy Service (i.e .proxy file)

Service Name: EmployeeLoanProcessPS (append PS to the proxy service as a naming standard)
Location: browse through “ProxyService” folder we created in earlier step
Transport: http (keep it as it is)

Keep “Generate Pipeline” checked for creating pipeline along with Proxy Service

Click Next

23_OSB-12c_Service_Callout_and_Routing_Table_example_Proxy_Service_wizard_10a

 

Step 10.b: Select “WSDL” from four available options

And browse to wsdl location by clicking first icon with green arrow mark pointing towards right hand side (i.e.; wsdl is placed under “Resources/wsdl” folder)

Choose “Application” and select correct WSDL we have stored for this project

Finally click OK and then click Next

Note: WSDL file of EmployeeLoanApprovalService(PS) & other two loan approval service namely viz., DefaultLoanApprovalService(BS) and HRManagerLoanApprovalService(BS) are roughly similar and their request/response pattern are almost similar with one extra element for Business Service for Employee Validation (employeeDetailValidated)

24_OSB-12c_Service_Callout_and_Routing_Table_example_Proxy_Service_wizard_10b

 

Step 10.c: In step 2 of Create Proxy Service wizard –> populates wsdl file with port after reading the WSDL file we have chosen in the previous step

Click Next

25_OSB-12c_Service_Callout_and_Routing_Table_example_Proxy_Service_wizard_10c

 

Step 10.d: In step 3 of Create Proxy Service wizard –> populates endpoint URI

Click Finish

26_OSB-12c_Service_Callout_and_Routing_Table_example_Proxy_Service_wizard_10d

Finally Proxy Service is created

 

Proxy Service is created on the Proxy Services lane and this resides under “ProxyService” folder

27_OSB-12c_Service_Callout_and_Routing_Table_example_Proxy_Service_created

Step 11: Double-click on the EmployeeLoanProcessPSPipeline which opens up in new editor with .pipeline extension (green-color round-cornered rectangle type figure in the Pipelines/Split Joins)

Opens up EmployeeLoanProcessPSPipeline.pipeline file in an editor

28_OSB-12c_Service_Callout_and_Routing_Table_example_Proxy_Service_pipeline_editor

 

Step 12: Service Callout node

As per our business case requirement stated in the first section of this article, we need to invoke employee validation service using “Service Callout” node to get to know whether employee details are validated or not

Outcome of Employee Validation Service is: Yes or No

And this value needs to be set in the request document/body before invoking the Business Service (using “Routing Table” node in this example)

 

Step 13: Drag and drop “Pipeline Pair” from “Message Flow” under the category “Nodes

Note: We can’t directly drag & drop “Service Callout” node to Proxy Service’s Message Flow. So, first drag & drop “Pipeline Pair” node and then drag & drop “Service Callout” node inside stage1 of Request Pipeline of the PipelinePairNode1

29_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Pipeline_Pair

 

Drag and drop “Service Callout” from “Message Flow” under the category “Communication

Note: Drag & drop “Service Callout” inside Stage1 of Request Pipeline of the PipelinePairNode1

30_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Service_Callout

Error: Red-ribbon type error mark on top-right corner is because, we haven’t set correct mandatory values for Service Callout node (after setting conditions & saving would vanishes all errors)

 

Step 14: Next step is to set mandatory values for Service Callout –> which will vanishes all errors after saving

First select the service to be invoked i.e.; in this example, EmployeeValidationServiceBS

Finally click OK

31_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Service_Callout_select_service

 

Select the correct operation to be invoked; in this case we have got just one operation to validate the employee details

Operation: validateEmployeeDetail
Configuration: Configure Payload Document (Make sure to select this option out of 2)

Set the mandatory Payload values for both Request & Response i.e.; setting the message context variable as below

Request –> Payload* –> requestValidateEmployeeDetail
Response –> Payload* –> responseValidateEmployeeDetail

Points regarding the Service Callout request & response variables

  • Request variable “requestValidateEmployeeDetail” to be set using “Assign” node prior to Service Callout node in message flow
  • Extract validation details (i.e.; Yes or No) from the response variable “responseValidateEmployeeDetail” and set it in the context variable using “Assign” node

32_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Service_Callout_set_mandatory_values

 

Step 15: Setting/assigning request document à in the request variable of the “Service Callout” for Employee Validation Service using “Assign” node

Drag and drop “Assign” from “Message Flow” under the category “Message Processing

Assign Properties:

Value*: Click “fx” which opens Expression Builder –> set the request document for Employee Validation Service (move to next step for setting this expression)

Variable*: requestValidateEmployeeDetail (this is same message context variable we have set in the request Payload of the Service Callout)

33_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Assign_node

 

Click “fx” to set request document for Employee Validation Service

To get the request document sample, we need to test the Employee Validation Service separately at the Business Service level

Error: This is due to, we haven’t set the namespace for this request document –> we will take care of this error in the folowing step

34_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Assign_setting_request_document

 

Add namespace for request document of the Employee Validation Service

User Namespace:

Prefix: val
URL: http://benchresources.in/entities/ValidateEmployeeDetail

Finally click OK

35_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Assign_adding_namespace

 

Step 16: Extract response document from response variable of the “Service Callout” and set in the message context variable

Drag and drop “Assign” from “Message Flow” under the category “Message Processing

Assign Properties:

Value*: Click “fx” and move to the next step
Variable*: employeeValidated

Note: we will use this message context variable “employeeValidated” in the next step (to set in the request body before invoking Business Service)
36_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Assign_to_extract_response

 

Below expression used to extract the content value from the response variable of the Service Callout

Expression: $responseValidateEmployeeDetail/val:validated/text()

Finally click OK

Note: This message context variable “employeeValidated” will be set in the request body using “Insert” node in the next step

37_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Assign_set_expression_to_extract

 

Step 17: Insert message context variable “employeeValidated” in the original request body (before invoking either of the Business Service)

Drag and drop “Insert” from “Message Flow” under the category “Message Processing

Insert Properties:

Value*: click “fx” and move to next step for setting the Expression
Position*: after
Location*: body
XPath: $body/loan:ProcessLoanRequestType/loan:amountInDollars

38_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Insert_node

 

Click “fx” and set below Expression

Expression: <loan:employeeDetailValidated>{$employeeValidated}</loan:employeeDetailValidated>

Finally click OK

39_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Insert_node_mandatory_expression

 

Step 18: Routing Table node

Routing Table: It is a set of routes wrapped in a switch-style condition table

Drag and drop “Routing Table” from “Message Flow” under the category “Route

Value*: $body/loan:ProcessLoanRequestType/loan:amountInDollars/text()

Advantage of OSB 12c over OSB 11g

  • When we drag and drop the Routing or Routing Table node, it automatically have a Route node in place
  • Whereas in 11g, we need to drag and drop Route node first before Routing or Routing Table node

40_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Routing_Table_set_element_to_be_compared

Error: Red-ribbon type error mark on each top-right corner is because, we haven’t choose/set any specific business service

 

Click fx which opens XQuery Expression Builder and set the below expression

Expression: $body/loan:ProcessLoanRequestType/loan:amountInDollars/text()

Finally click OK

Note: manually need to add “/text()”

41_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Routing_Table_set_Expression

 

Step 19:

Case 1: amount <= 4000

Click first case under Routing Table

Select “<=” operator from drop-down and set the value to “4000” using Expression Builder

42_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Routing_Table_set_Case_1

 

Add business service to Routing node in the Routing Table

Click on Routing –> opens corresponding properties in the dialog box below

Click browse icon next to Service* –> opens “Resource Chooser” –> select service to be routed

Finally Click OK

43_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Routing_Table_set_Routing_for_Case_1

Similarly, repeat the same steps for the second case (>4000)

 

Case 2: amount > 4000

Click second case under Routing Table

Select “>” operator from drop-down and set the value to “4000” using Expression Builder

44_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Routing_Table_set_Case_2

 

Add business service to Routing node in the Routing Table

Click on Routing –> opens corresponding properties in the dialog box below

Click browse icon next to Service* –> opens “Resource Chooser” –> select service to be routed

Finally Click OK

45_OSB-12c_Service_Callout_and_Routing_Table_example_drag_drop_Routing_Table_set_Routing_for_Case_2

Similarly, repeat the same steps for the default case

In this example, actually we don’t need that but this needs to be set. So, repeat the same steps and select Default Loan Approval Service

 

Step 20: Time to test !!

Testing Service Bus project –> deploying into IntegratedWeblogicServer

46_OSB-12c_Service_Callout_and_Routing_Table_example_testing_Run

 

Step 21: Testing

This will open our traditional OSB console, where we can input and execute this sample mock service.

Enter necessary employee details requesting a loan amount of $. 3750

Note: Amount entered by the user is less than $. 4K, therefore OSB will route to default loan approval service

47_OSB-12c_Service_Callout_and_Routing_Table_example_testing_Run_Execute

Note: Make sure enterprise web service is up and running, otherwise error will be thrown

 

Request document and Response document

48_OSB-12c_Service_Callout_and_Routing_Table_example_testing_Run_Execute_Result_case1

 

Similarly, we can test for other case i.e.; entering loan amount of greater than $. 4K where OSB routes to HR Manager Approval service

49_OSB-12c_Service_Callout_and_Routing_Table_example_testing_Run_Execute_Result_case2

 

The same can be tested through Service console (OSB console) at http://localhost:7101/sbconsole (change the port number, if you have configured something else)

 

Download project

EmployeeLoanService (13kB)
ServiceCalloutAndRoutingTableSB (26.7kB)

 

References

https://docs.oracle.com/middleware/1213/osb/develop/osb-pipeline-design.htm#OSBDV2378
http://docs.oracle.com/cd/E28280_01/admin.1111/e15867/modelingmessageflow.htm#i1103454
https://docs.oracle.com/middleware/1213/osb/develop/osb-pipeline-actions.htm#OSBDV2493
https://docs.oracle.com/middleware/1213/osb/develop/osb-pipeline-design.htm#OSBDV2409

 

Read Also:

 

Happy Coding !!
Happy Learning !!

Oracle OSB 12c: Java Callout and Routing Table example
Oracle OSB 12c: Conditional Branch example
  • Soumya Mallick

    Do u have any error handling POCs done

    • Ashok

      Thanks for this blog..clear explanation. Learner easily understanding.

      • SJ

        Thanks Ashok !!

        • Mahesh P

          Hi SJ,

          how to deploy EmployeeLoanService project to have external web services

          • SJ

            Deploy to some application server like tomcat, JBoss, or weblogic, websphere, glassfish

  • Inderjeet Singh

    Hi ,
    Can you please tell me that how to import the above project ,as there is no .jpr file in the project folder..

    • SJ

      Inderjeet,

      A new OSB project added to Download Project section.
      Download this file to get .jpr file

  • Inderjeet

    Hi,
    Can u please upload the .jar file,because the project file which u have uploaded is having extension as.7z which firstly required to be converted into .jar.

    • SJ

      Inderjeet,

      Don’t need to convert .7z to .jar
      Instead unzip the .7z file and inside that you will find the .jar file
      Try it and let us know whether you able to get the required file

  • Inderjeet

    Hi,
    Your blogs are preety much informative.So request you to please upload some more stuff related to OSB-12c.We find it really interesting to read your blogs as all the inplementations are fully explained without even missing a single step.Thanks

    • SJ

      Thanks Inderjeet !!

  • Inderjeet Singh

    Hi,
    Can u upload some more stuff related to 12c.As i am a beginner in SOA-OSB world.So if possible,can u upload some more hands on some of the adapters.

    Thanks & Regards
    Inderjeet Singh

  • Aravind

    Hi,
    I have a small doubt on 14th Step,under service callout properties i can able to select the the Business Service and the operation.But under the request and response payload i can able to see only the attachments,body,header and outbound.I am not able to get the custom variable there like you get.Can you explain that procedure

    • SJ

      Aravind,

      It is user-defined variable. In fact, you can define any variable name like “aravind” and later it is used in Step 16: under assign activity.
      hope, it clears your doubt

      • Aravind

        Hi SJ,
        Thanks for the immedidate Response.Can you please explain how to create User-defined varible.Because I am new to OSB So I don’t know about it

        • SJ

          Aravind,

          Simply provide some meaningful name in the request and response text-box and use it the next step to extract values.
          hope it helps you !!