Oracle SOA Suite Online Training

Interested in learning Oracle SOA Suite 12c?
Learn from the author of this blog!
A complete and comprehensive course on the #1 platform on SOA - Oracle SOA Suite

Click here to find the complete course details
Click here to check the first session on Oracle SOA Suite 12c

================================================================================================

Working with a Database Adapter - Part 2

contd. after Part 1

Creating a webservice Client
Drag and drop "Web Service" from the component palette to the exposed Services swim lane. This opens up the WebService Wizard
Name it DBServiceClient.
Choose Generate WSDL from Schema option in the WSDL URL field in the wizard (shown in the figure)

 
This opens up a Create WSDL wizard, where you'll choose Synchronous Interface, and map its input and output parameters as per the defined schema


Click on Add Message Part in Input of the wizard, click on browse button in URL section, select the request part from DBAdapterFormat.xsd that we have created in the initial phase
Similarly, add the output message part as well.


 
After adding both input and output message parts, the wizard looks similar to this

 
This finishes the creation of the client web service.

Now, the question is how the client web service and the DBAdapter Service communicate with each other.

We make use of a Mediator for this task of linking each of the services.
A mediator, as its name implies, mediates between two different services, and offers various functionalities intercepting the request. In this case, it manipulates the response from the DBAdapterService to transform firstName and lastName to fullName.

Creating a Mediator
Drag and drop a Mediator from the component Palette in to the Components swimlane.
You may choose to Define Interface Later during its creation.
 
Now, wire DBServiceClient to Mediator and Mediator to EmpDBAdapterService


Double click on the Mediator to open its configuration file, a .mplan file.
In this file, we can configure various options for the mediator.
If you observe, the mplan file has 2 sections in the Static Routing Section, one for request and the other for the reply.

In our case, we will map the DBServiceClient's input to the EmpDBAdapterService's input and EmpDBAdapterService's output to the DBServiceClient's output
For this, click on the browse-like button(highlighted in the figure above) on the Transform Using option. It opens up a new window, where we select Create New Mapper File option.
This opens up the xsl transformation wizard where we map input from client to the service. It is straight forward, just drag a line b/w empId in the left to the right as shown in the figure below

 
Now, create a new mapper file for the response, in the Synchronous Reply section
The transformation that you do here is to concat the firstName and lastName from the Service to the fullName in the client.
From the component palette, In String Functions, drag concat function to the middle of the transform wizard

 
You can double click the concat function icon to do any additional modifications like adding spaces, extra characters, etc.
Similarly, link salary on both sides

This completes our example. Lets deploy and test it.

To deploy, right click on the prj --> Deploy --> select SOA Server



Oracle SOA Suite 11g provides a unified console to test and manage all the Fusion Middleware deployments by Fusion Enterprise Manager, also called EM.
Go to soa_domain --> SOA --> DBAdapterExample --> Test
Give an input of 101 (employeeId), and check the result.

 Input

 Output
 
Hope this gives you a good understanding on what is a Database Adapter, and how to use it in SOA Applications.
In my next blog, I'll take you through some of many nice to know features of the Database Adapter.

- RaviKiran

5 comments:

  1. Hi Ravi,

    After deploying the project , I am getting the below error. Could you please help me.

    JCABinding=> JCABinding=> DBAdapterExampleProject:EmpDBAdapterService [ EmpDBAdapterService_ptt::EmpDBAdapterServiceSelect(EmpDBAdapterServiceSelect_inputParameters,EmployeesCollection) ] JNDI lookup of 'myConn' failed due to: String index out of range: -1


    Thanks and Regards,
    Prasad

    ReplyDelete
    Replies
    1. Hi
      Can you check the JNDI connection setting in console?

      Delete
    2. This comment has been removed by a blog administrator.

      Delete
  2. Please help me as soon as possible.....................>

    ReplyDelete
    Replies
    1. Hi
      The issue says 'JNDI lookup of 'myConn' failed'
      Please check the Outbound Conn pool setting and see if the data source is present, and check the datasource configuration.
      Restart the dbadapter deployment from the console and test

      Delete