Friday, June 11, 2010

FAQ #25 - How to get started with SOA Suite 11g R1, Pt. 4

Introduction

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=







Sunday, June 6, 2010

FAQ #24 - How to get started with SOA Suite 11g R1, Pt. 3

Introduction

In this third part of getting started with SOA Suite 11g we will continue the example that we started in part two by introducing a Web Service binding to our project.

Main Theme

Start by opening the EmployeeInquirer project in JDeveloper. Prior to creating the Web Service binding for our project, the necessary XML schema definition (XSD) file describing the web service request, reply and error must be constructed. We will create a new XSD file by selecting File | New... and XML Schema from the General | XML category of the New Gallery dialog.


In the Create XML Schema dialog enter the schema File Name and Target Namespace as it is shown below and click OK.


JDeveloper will proceed with creating the XSD file and it will open it in the Design editor:


The first thing we will do is rename the exampleElement generated by default to employeeInfoRequest. You can do this by selecting the element in the Design editor and changing its name attribute in the Property Inspector. If the Property Inspector is not shown, select View | Property Inspector from the menu to display it.

Next, right-click on the employeeInfoRequest element and select Insert inside element | sequence to create a xsd:sequence.


Similarly right-click on the newly created sequence and select  Insert inside sequence | element to create the employee's id element for the request.


Select the newly created element and change its name to EmployeeId and its type to xsd:string in the Property Inspector.

Now let's create two more XSD elements: one for the web service reply and another to store an error message. Your final XSD should look like this:


Now we are ready to create the web service binding. Switch to the composite Design, grab the Web Service icon from the Component Palette and drop it on the Exposed Services of the design canvas. This will initiate the Create Web Service wizard.


Enter getEmployeeInfoById for the name of the web service and click the gear icon next to the WSDL URL edit box to generate the web service WSDL. This will bring up the Create WSDL dialog where we will specify the web service message schemas.


With the Request tab selected, click on the magnifying glass icon next to the URL edit field and browse for the XSD file that you created earlier. In the Type Chooser dialog that is presented, expand the Project Schema Files and the EmployeeInquirer.xsd nodes and select employeeInfoRequest.


Repeat for the Reply and Fault tabs of the Create WSDL dialog selecting employeeInfoReply and employeeInfoError respectively. When done click OK on the Create WSDL dialog. The Create Web Service dialog should look like this:


Finally click OK on the Create Web Service dialog to complete the creation of the web service. The composite should now look as it is shown below with the getEmployeeInfoById web service shown on the Exposed Services part of the design canvas.


This concludes the creation of the Web Service binding.

Conclusion

In this part we created a Web Service binding for our EmployeeInquirer composite. We will complete and test the composite in the next part by wiring the web service to the Database Adapter that we developed previously using a Mediator component.

Until the next time keep on JDeveloping!







Related Posts Plugin for WordPress, Blogger...