Oracle OSB 12c: Operational Branch example

In this article, we will explore the use of Operational Branch node in OSB 12c

With the use of Operational Branch node, we can route the incoming requests to different business service based on the operation name (various operations under the same service)

Business case requirement:

  • There are two operations exposed to retrieve Book Information
    1. Retrieve book information based on ISBN request number
    2. Get book information from the supplied input request Book Name
  • This will query the database (actually through exposed web service) based on the isbnNumber or bookName provided in the request from their respective operations
  • Returns book information for valid ISBN number or valid Book Name
  • Else no book found

Assumptions:

  • There is a exposed web service for Book service up & running on the application server
  • This web service can be invoked only through OSB
  • For demo purpose, we will copy the WSDL and Schema files and paste in our Service Bus project under “Resources” folder
    For more details & understanding about this web service, refer this article
  • Actually one more operation “getBookDetailsByBookName” added to this service to demonstrate operation branch example
  • Download this web service project from download section (scroll down to last)

Let’s get started with designing OSB modules for Operational Branch example in Oracle JDeveloper 12c IDE

 

Step 1: Open New Project

File Menu –> New –> Project

1_OSB-12c_Operational_Branch_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_Operational_Branch_example_New_project_wizard

Note: Comparing this wizard with the one we have created in the last 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

Click Finish

3_OSB-12c_Operational_Branch_example_New_project_wizard_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_Operational_Branch_example_New_project_create_folder

 

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

Finally click OK –> to create folder

5_OSB-12c_Operational_Branch_example_New_project_create_folder_b

 

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 Schema and WSDL files

6_OSB-12c_Operational_Branch_example_New_project_create_folder_c

 

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

As we discussed in the assumption section, there is one web service up & running at URL http://localhost:8080/Metro-JAX-WS-Top-Down/services/BookService?wsdl

So we will copy those 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_Operational_Branch_example_New_project_schema_wsdl

 

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

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

8_OSB-12c_Operational_Branch_example_New_project_HTTP_component

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

 

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

Service Name: BookServiceBS (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_Operational_Branch_example_New_project_Business_Service_wizard_a

 

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_Operational_Branch_example_New_project_Business_Service_wizard_b

 

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_Operational_Branch_example_New_project_Business_Service_wizard_c

 

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_Operational_Branch_example_New_project_Business_Service_wizard_d

 

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

13_OSB-12c_Operational_Branch_example_New_project_Business_Service_wizard_e

 

Step 8: Create Proxy Service and add pipeline

Drag and drop HTTP component from Technology palate to Proxy Services

14_OSB-12c_Operational_Branch_example_New_project_Proxy_Service_wizard_a

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

 

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

Service Name: BookServicePS (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

15_OSB-12c_Operational_Branch_example_New_project_Proxy_Service_wizard_b

 

We will use the same WSDL for this demo example

16_OSB-12c_Operational_Branch_example_New_project_Proxy_Service_wizard_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

17_OSB-12c_Operational_Branch_example_New_project_Proxy_Service_wizard_d

 

In step 3 of Create Proxy Service wizard –> populates endpoint URI

Click Finish

18_OSB-12c_Operational_Branch_example_New_project_Proxy_Service_wizard_e

 

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

19_OSB-12c_Operational_Branch_example_New_project_Proxy_Service_wizard_f

 

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

Opens up a BookServicePSPipeline.pipeline file in an editor

20_OSB-12c_Operational_Branch_example_New_project_pipeline_editor

 

Step 11: Operational Branch node

We will use operational branch node in this example, though it is not very much required here as both exposed Proxy Service & Business Service are based on the same WSDL

We are using operational branch node for demo purpose which can be possibly applied in very complex OSB design cases as well (where both PS & BS aren’t based on the same WSDL)

Operational Branch: We can have different routes based on the operations exposed at the Proxy Service level

In this example, we got two operations exposed at the Proxy Service level namely

  • getBookByISBNRequestNumber
  • getBookDetailsByBookName

So operational branch node helps to have different branches based on the number of operations exposed or even less than that depending on the business requirements with always mandatory default branch

Reason for default branch is to route the incoming request, if nothing matches the exposed operations at the Proxy Service level

 

Step 12: Drag and drop “Operational Branch” from “Message Flow” under the category “Nodes

21_OSB-12c_Operational_Branch_example_New_project_drag_op_branch

 

Add one more branch to the already existing two branches (one branch for one operation and another mandatory default branch)

22_OSB-12c_Operational_Branch_example_New_project_drag_op_branch_add

 

Step 13: Add Routing node to each operations (skip adding Routing node to Default branch)

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

Advantage OSB 12c over OSB 11g

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

23_OSB-12c_Operational_Branch_example_New_project_drag_op_branch_add_routing

Note: once we select and set the business service in the Routing, then red-ribbon type error mark will vanish after saving all

 

Step 14: Add business service to all Routing node

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

24_OSB-12c_Operational_Branch_example_New_project_drag_op_branch_add_routing_add_BS

 

Similarly, do it for second operation as well (as said earlier red-ribbon type error vanished)

25_OSB-12c_Operational_Branch_example_New_project_drag_op_branch_add_routing_after_adding_service

 

Step 15: Add transformation logic for the Proxy Service (i.e.; BookServicePSPipeline.pipeline) using assign/replace node

Generally,

  • Request document to the input of OSB and request document to the input of Enterprise Service isn’t same at all time
  • So, we need to add transformation logic to convert the request document received at the input of OSB to the input of External/Business Service
  • Judiciously use assign, replace, rename nodes
  • Invoking other services using “Service Callout” or “Java Callout” node to enrich the input request document to the External/Business Service

Note: Above points implies for response thread in the response pipeline of the pipeline-pair

But in our case, we don’t need any transformation logic as both Proxy Service and Business Service are based on the same WSDL

Time to test !!

Testing Service Bus project –> deploying into IntegratedWeblogicServer

26_OSB-12c_Operational_Branch_example_New_project_op_branch_example_testing_run

 

Step 16: Testing

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

We will choose second operation “getBookDetailsByBookName

Enter necessary detail in the Request document –> Click Execute

Enter Book Name as “Microbiology

27_OSB-12c_Operational_Branch_example_New_project_op_branch_example_testing_run_execute

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

 

Request document and Response document

28_OSB-12c_Operational_Branch_example_New_project_op_branch_example_testing_result_output

 

Download project

Metro-JAX-WS-Top-Down (11kB)

References

http://docs.oracle.com/middleware/1213/osb/develop/osb-pipeline-jdeveloper.htm#OSBDV88545
http://docs.oracle.com/middleware/1213/osb/develop/osb-pipeline-flow.htm#OSBDV2469
http://docs.oracle.com/middleware/1213/osb/develop/osb-pipeline-design.htm#OSBDV2359

 

Read Also:

Happy Coding !!
Happy Learning !!

Oracle OSB 12c: Conditional Branch example
Oracle OSB 12c: Hello World service with both Business and Proxy Service