In an earlier blog I showed how to service
enable a database on OSB 12c . The business
service created as we saw is strongly coupled to the database. A change on the
database (table name, data type or column name) would impact the interface
created. This is something that we want to avoid when using the service in a
larger context in Service –Oriented Architecture (SOA).
In this blog post, I will explain how to
create a proxy service in OSB 12c that can act as an atomic service to decouple
We start by creating a Proxy Service. In
my sample project, I have created a folder named ProxyService that would contain our Proxy services in order to organize
the OSB project.
To create the Proxy Service, Right click |
New | Proxy service.
In the Create Proxy Service dialog, give
the service a name and location it should be created. In the definition, I am
using a WSDL file with an independent interface that defines a service contract
different from that of the Business service that is tightly coupled with the
The Proxy service is created and can be
seen in the SBProject design view.
Creating the Transformations
Next we create two transformation operations
to translate messages requests formats from the Proxy service to the business
service and the way around.
Right Click on Transformation folder (I
created this in the project for better organization of the project artifacts)
and then New|XQuery File Ver 1.0
A Create Xquery Map Main module dialog
box appears to add source and target WSDLs (or schema). Click on the Plus (+)
button to add the source WSDL or XML schema.
Press Browse button to select a Schema
In the Type Chooser dialog, we will select getEmployeeDetails request element in our sample Schema.
Give a name to the Function Parameter and
Next, we specify the Target for the
Once we complete the creation of the
XQuery file, it opens in Jdeveloper. With the XQuery Mapper, we can now map the
items from Source to Target. For more Xquery Transformation, see Creating
Transformations with the XQuery Mapper.
We would also create
the XQuery transformation of the response. It is similar to the one we just
created for the request, only this time the Source XML Schema is the Business
Service and the Target is the Proxy Service XML Schema and we select the
response elements in both XML Schemas.
Configuring the Proxy Service
In the design view, we will use a Replace
action (drag this from the component window) in the Request and Response
Actions of the Routing action.
With the Replace Action, the existing
body is reused and only the node contents is replaced
In the XQuery Transformation Expression Builder, we have to specify the
binding of the XQuery variable element.
Deployment and Testing in the OSB
Right Click on .pipeline file and Run.
Note that before deployment to Weblogic, we
would have created the Datasource and Connection Factory as in this blog.
Now, to test we will select the getEmployeeDetail operation and in the
payload, we will use 100 for ID of the employee
The successful response returned from the
Proxy service is a canonical format of the information form the database.
In this blog post, we have seen how to
create a simple proxy service that decouples the database from the business
service created from our JCA database adapter in Oracle Service Bus 12c.
In Service – Oriented Architecture (SOA) Middleware component
however, the best practice is NOT to implement SQL code (INSERT, SELECT, DELETE,
UPDATE, etc) here to easily allow changes to database queries without impacting
the service interface.
In my next blog, we will use a simple
PL/SQL package to communicate with the database and expose the business service
based on the package attributes in Oracle Service Bus 12c.