Saturday, May 29, 2010

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

Introduction

In FAQ #22 - How to get started with SOA Suite 11g R1, Pt. 1 we covered the installation of SOA Suite 11g R1 on a development environment. We will continue in this part with setting up the SOA development environment in JDeveloper and developing a simple Database Adapter Service to return the Employee's information from the HR schema. Let's get down to it.

Main Theme

Creating the Database Adapter service

To develop SOA projects in JDeveloper an additional extension, called SOA Composite Editor, must be installed. The extension can be downloaded either via the JDeveloper Help | Check for Updates... menu option or directly from the Oracle Fusion Middleware Products Update Center web site.



Once downloaded and installed it makes available additional functionality to support developing SOA projects. To begin with your first SOA application, start JDeveloper and from the File | New... menu create a SOA Application using the New Gallery wizard.


On the Name your application page of the wizard enter the application name. Specify your project name on the Name your project page of the wizard. For the purpose of this example, we will call the project EmployeeInquirer. When asked to select a Composite Template on the Configure SOA settings page, select an Empty Composite.


Finally click Finish to complete the creation of the SOA application and its project. JDeveloper will proceed to create the project artifacts and display the composite Design screen as shown below.


As you can see, the composite is presented divided in 3 sections: Exposed Services, Components and External References. For this example, we will add a Database Adapter Service to the External References section. So grab a Database Adapter from the Service Adapters section of the SOA Component Palette and drop it to the External References section of the composite design canvas. This will start the Adapter Configuration wizard. Click Next on the Welcome screen. On the Service Name page specify the service name for the Database Adapter. For the purpose of this example let's call the service name getEmployeeInfo. This service will return some employee information based on some input.


On the Service Connection page we will specify a connection to the HR schema in our database. You can do the connection right from this page by clicking the green plus icon.


Notice that based on the connection name that we specified - HrConnection - a default JNDI name - eis/DB/HrConnection - was generated. Before deploying the application to the application server, we must create and configure this database resource. For now we will continue with the Adapter Configuration by clicking Next. On the Operation Type page we will select Perform an Operation on a Table and then check on Select.


Clicking Next will present the Select Table page.



On this page click on the Import Tables... button to import the EMPLOYEES table from the HR schema. On the Import Tables dialog click Query to query the database tables, select the EMPLOYEES table and shuttle it to the Selected section of the dialog.


Now click OK to bring the selected EMPLOYEES table to the Select Table page of the Adapter Configuration wizard.


Click Next and once more Next on the Relationships page. On the Attribute Filtering page select only the firstName and lastName attributes and click Next.


On the Define Selection Criteria page, we will add a parameter to the query. This parameter will be set to the Employee's identifier at runtime. So click on the Add... button in the Parameters section and enter inEmployeeId as the parameter name on the Parameter Name dialog.


While on the Define Selection Criteria page, click on the Edit.. button. This will bring up the Expression Builder dialog. Click the Add... button on the Expression Builder dialog and specify the expression employeeId EQUAL inEmployeeId by selecting employeeId for the First Argument, EQUAL for the Operator and the Parameter inEmployeeId for the Second Argument.


The SQL on the Define Selection Criteria page of the wizard should look like this now:


Click Next to go to the Advanced Options page. Leave the recommended options as they are and click Next once more. On the last page click Finish to complete the definition of the getEmployeeInfo Database Adapter Service.


JDeveloper proceeds with the creation of the getEmployeeInfo Database Adapter Service and displays it on the External References section of the composite design canvas.


This concludes the creation of the Database Adapter Service.


Conclusion

In this part we setup the environment in JDeveloper for developing SOA applications. We created a simple Database Adapter Service called getEmployeeInfo for inquiring an Employee based on the Employee's identifier. We will continue this introduction to SOA development next time by creating a Web Service binding and hooking it up to the getEmployeeInfo Database Adapter service.

Until the next time keep on JDeveloping!







No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...