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

In the previous article, we have demonstrated a simple Service Bus project (or OSB module) with only Proxy Service exposed which returns greeting message “hello” to the entered user name

But to leverage the full use of Oracle Service Bus, we need to design Service Bus projects using both Proxy Service & Business Service where

  • Business Service interacts with the Enterprise Information Systems or SOA/BPEL modules or any exposed Web Services
  • Proxy Service’s message flow helps to validate, enrich and transform the incoming request to required format before routing/operating to Business Service (follows VETRO pattern)

Business case requirement:

  • User enters ISBN number to retrieve book information
  • This will query the database (actually through exposed web service) based on the isbnNumber provided in the request
  • Returns book information for valid ISBN number
  • Else no book found for entered ISBN number

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 about this web service, refer this article





Let’s get started with designing OSB modules in JDeveloper 12c IDE

Every Oracle Service Bus projects should reside under any of the Service Bus Application. In the last article for simple HelloWorldSB project, we have created Service Bus Application.

So we will use same Service Bus Application for this demo

This time instead of starting from “Service Bus Application with Service Bus Project” wizard, we will use same Service Bus Application and directly start creating Service Bus project

Step 1: Open New Project

File Menu –> New –> Project

1_OSB-12c_Hello_World_example_PS_BS_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_Hello_World_example_PS_BS_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

 

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_Hello_World_example_PS_BS_New_project_wizard_name_dir

 

New Service Bus project is created with required artifacts

4_OSB-12c_Hello_World_example_PS_BS_New_project_template

 

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

5_OSB-12c_Hello_World_example_PS_BS_New_project_folder_create

 

Create Folder wizard –> enter folder name like, for example “ProxyService” for Proxy Service

Finally click OK –> to create folder

6_OSB-12c_Hello_World_example_PS_BS_New_project_folder_create_b

 

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

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

7_OSB-12c_Hello_World_example_PS_BS_New_project_folder_create_final_c

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

8_OSB-12c_Hello_World_example_PS_BS_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)

9_OSB-12c_Hello_World_example_PS_BS_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

10_OSB-12c_Hello_World_example_PS_BS_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

11_OSB-12c_Hello_World_example_PS_BS_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

12_OSB-12c_Hello_World_example_PS_BS_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

13_OSB-12c_Hello_World_example_PS_BS_New_project_Business_Service_wizard_d

 

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

14_OSB-12c_Hello_World_example_PS_BS_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

15_OSB-12c_Hello_World_example_PS_BS_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

16_OSB-12c_Hello_World_example_PS_BS_New_project_Proxy_Service_wizard_b

 

We will use the same WSDL for this demo example

17_OSB-12c_Hello_World_example_PS_BS_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

18_OSB-12c_Hello_World_example_PS_BS_New_project_Proxy_Service_wizard_d

 

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

Click Finish

19_OSB-12c_Hello_World_example_PS_BS_New_project_Proxy_Service_wizard_e

 

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

20_OSB-12c_Hello_World_example_PS_BS_New_project_Proxy_Service_wizard_f

 

Step 20: Connect BookServicePSPipeline with BookServiceBS HTTP service

21_OSB-12c_Hello_World_example_PS_BS_New_project_services_connected

 

And double-click on the BookServicePSPipeline which opens up in new editor with .pipeline extension

22_OSB-12c_Hello_World_example_PS_BS_New_project_pipeline_transfromation

 

Step 21: 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 to transform the request document
  • 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

Just pass through the request document to the underlying business service without any real transformation

So with this our design is complete

Time to test !!

Testing the Service Bus project deploying into the IntegratedWeblogicServer

23_OSB-12c_Hello_World_example_PS_BS_New_project_testing_run

 

Step 22: Testing

This will open our traditional OSB console, where we can input and execute this sample service. Enter necessary detail in the Request document –> Click Execute

Enter ISBN number as “ISBN-2134

24_OSB-12c_Hello_World_example_PS_BS_New_project_testing_run_execute

 

Request document and Response document

25_OSB-12c_Hello_World_example_PS_BS_New_project_testing_result_output

 

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)

References

http://docs.oracle.com/middleware/1213/osb/develop/osb-overview-design-jdev.htm#OSBDV87879

Happy Coding !!
Happy Learning !!