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)
1. 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
2. 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
3. Operational Branch example :
Step 1: Open New Project
File Menu –> 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
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
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
Create Folder wizard –> enter folder name like, for example “BusinessService” for Business Service
Finally click OK –> to create folder
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
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
3.1 Business Service :
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)
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
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
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
In step 3 of Create Business Service wizard –> populates the endpoint URI for the exposed web service to be invoked
Click Finish
Business Service is created on the External Services lane and this resides under “BusinessService” folder
3.2 Proxy Service :
Step 8: Create Proxy Service and add pipeline
Drag and drop HTTP component from Technology palate to Proxy Services
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
We will use the same WSDL for this demo example
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
In step 3 of Create Proxy Service wizard –> populates endpoint URI
Click Finish
Proxy Service is created on the Proxy Services lane and this resides under “ProxyService” folder
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
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)
3.3 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”
Add one more branch to the already existing two branches (one branch for one operation and another mandatory default branch)
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
3.4 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
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
Similarly, do it for second operation as well (as said earlier red-ribbon type error vanished)
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
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”
Note: Make sure enterprise web service is up and running, otherwise error will be thrown
Request document and Response document
4. Download project :
Metro-JAX-WS-Top-Down (11kB)
Related Articles :
- Oracle SOA 12c – Installation steps using Single Installer
- Oracle SOA 12c – Domain creation steps
- Oracle OSB 12c – Hello World mock service with Proxy Service
- Oracle OSB 12c – Hello World service with both Business and Proxy Service
- Oracle OSB 12c – Operational Branch example
- Oracle OSB 12c – Conditional Branch example
- Oracle OSB 12c – Service Callout and Routing Table example
- Oracle OSB 12c – Java Callout and Routing Table example
- Oracle OSB 12c – File Polling/Reading and Writing using File Transport
- Oracle OSB 12c – File Polling/Reading and Writing using FTP Transport and authentication via Service Account
- Oracle WebLogic – Steps to create Connection Factory and Queue
- JMS Client – To produce and consume messages in JMS Queue
- Oracle WebLogic – Steps to create Connection Factory and Topic
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
Happy Coding !!
Happy Learning !!