In this part of the How to get started with SOA Suite 11g R1 series we will conclude the EmployeeInquirer composite by wiring the Web Service binding to the Database Adapter using a Mediator component. We will also deploy the composite to WLS and test it using Enterprise Manager.
Main Theme
Defining the transformations using a Mediator component
Open the EmployeeInquirer project and bring up the composite Design screen. The Web Service binding and the Database Adapter should be displayed on the Exposed Services and on the External Services part of the design canvas respectively. From the Component Palette grab a Mediator component and drop it on the Components section of the composite. Enter RouteRequest for the Name of the mediator and click OK.
The composite design screen should now look as it is shown below:
Now that all components have been laid out on the screen we can wire them together to define their interactions. First we will wire the Web Service to the Mediator. Click on the green binding arrowhead icon on the top right of the Web Service and drag it to the left of the Mediator. Similarly wire the Mediator to the Database Adapter by clicking on the green arrowhead icon at the right of the Mediator and dragging it to the Database Adapter. When you are done the composite should look like this:
Now that the components are wired, we will add the transformation of the request/reply messages to the Mediator. We do this by double-clicking on the Mediator component. Doing so will bring up the Mediator editor.
We will use the editor to define the XSLT transformations to both the request and reply messages, so click on the transformation icon next to the Transform Using combo - pointed above by the red arrow - to bring up the Request Transformation Map dialog.
Click on the Create New Mapper File radio button and click OK. This will open the XSLT mapping editor.
To map the employeeId from the source - left side - to the target - right side, grab the employeeId from the source side and drop it on the employeeId on the target side. The resulting mapping should look like this:
Now save the mapping and close the mapping editor. Back on the Mediator editor repeat the mapping process for the reply.
On the Reply Transformation Map dialog click on the Create New Mapper radio and click OK.
This will open the XSLT mapping editor for the reply. Map the firstName and lastName elements from the source to the destination. The result mapping is shown below:
This concludes the definition of the Mediator and concludes the project. Next we need to setup the database resource for the Database Adapter and deploy the composite to WebLogic.
Creating the database resources in WLS
Creating the data source
The database resources are required by the Database Adapter in order to access the HR schema in the database. First we need to define the data source, so start WLS and log in to the Administration Console. Navigate to Services | JDBC | Data Sources using the Domain Structure tree on the left and click the New button on the Data Sources table to create a new data source.
In the Name field enter hrDatabase. For the JNDI Name enter jdbc/hrDatabase. Select the Database Type and click Next.
On the next screen select the Database Driver and click Next.
On the Transaction Options screen click Next. On the Connection Properties screen enter the database connection information for the HR schema and click Next.
On the Test Database Connection screen click the Test Configuration button to test the connection. If all is OK a Connection test succeeded message will be displayed. Click Next to continue.
On the Select Targets screen select your SOA server and click Finish to complete the creation of the data source.
WLS will create the data source and update the Data Sources table showing the hrDatabase data source you just created.
Creating the connection pool
Next we will create a connection pool for the DbAdapter application. Since DbAdapter uses a deployment plan, you will first need to create a directory on your physical SOA server machine to contain it. I have created under the %SOA_HOME%\soa directory and I called it DBPlan. The explicit path is C:\Oracle\Middleware\Oracle_SOA1\soa\DBPlan.
Using the WLS Administration Console click on the Deployments node of the Domain Structure tree and click on the DbAdapter application shown in the Deployments table.
On the Settings for DbAdapter screen click on the Configuration tab and then on the Outbound Connection Pools tab. Click New to create a new pool.
Select the javax.resource.cci.ConnectionFactory radio button and click Next.
On the JNDI name for Outbound Connection Instance screen enter the JNDI name as you have entered it for the Database Adapter definition in the EmployeeInquirer project. To ensure that it is entered correctly, return to JDeveloper, double-click on the Database Adapter in the composite and copy it from the Service Connection page.
After you paste it on the JNDI Name field click Finish.
At this point you will be asked for the deployment plan location. Enter the path that you created earlier and enter Plan.xml for the deployment plan and click OK. Confirm the deployment plan name in the Overview tab.
Now edit the connection pool you just created to associate it with the data source previously created. Click on the Configuration tab and then on the Outbound Connection Pools tab. Expand the javax.resource.cci.ConnectionFactory connection factory and click on the eis/DB/HrConnection instance.
On the Outbound Connection Properties page enter the data source name - jdbc/hrDatabase - in the Property Value field of the xDatabaseSourceName Property Name and click Save.
Finally we will need to update the DbAdapter application. Select Deployments from the Domain Structure tree and select the DbAdapter application. Click Update to update the application.
In the Update Application Assistant page select the Redeploy this application using the following deployment files: radio button and click Finish.
If all went well you should see these success messages:
Deploying the composite
Now we can deploy the composite to WLS. Create a connection to WLS, right-click on the project in the Application Navigator and select Deploy.
In the Deployment Action page of the Deploy wizard select Deploy to Application Server.
Click Next on the Deploy Configuration page. Select your WLS connection on the Select Server page and click Next. On the SOA Servers select your SOA server and click Next.
Verify the deployment summary on the Summary page and click Finish to start the deployment. If everything went OK you should see a BUILD SUCCESSFUL message in the SOA Log window.
The Deployment Log window should also indicate that the deployment went OK.
Testing the composite
To test the composite log in to the Enterprise Manager Fusion Middleware Control and click on the EmployeeInquirer composite on the SOA navigation tree. Then click on the Test tab.
On the Test Web Service page go the bottom of the page to the Input Arguments section and enter an Employee Id value - let's say 100, for the EmployeeId element of the request. Then click on the Test Web Service button.
The web service is executed and if everything goes OK the response will be shown on the Response tab.
This concludes our introduction to SOA Suite 11g.
Conclusion
In this series of posts we've seen how to get started with the SOA Suite 11g, from its installation to composite development - utilizing some of the basic components in JDeveloper, to testing the composite using Enterprise Manager Fusion Middleware Control. This just scratched the surface. SOA Suite is a vast technology with much more to offer.
Until the next time, keep on JDeveloping!
Code
http://code.google.com/p/jdeveloperfaq/downloads/detail?name=JDeveloperFAQNo25.rar&can=2&q=
No comments:
Post a Comment