11
Oracle SOA Suite 11g - Sample SAMPLE NAME: adapters-db-104-InformixStoredProcedure COMPONENT: DB Adapter for Stored Procedures OVERVIEW This scenario showcases a Database Adapter partner link (Outbound Adapter Service) that invokes a stored procedure on an Informix instance. The procedure has one input parameter. The value of the input parameter is used in a SELECT statement that performs a simple query to return rows from a table. The query is executed and left for the Stored Procedure Runtime to consume as a JDBC ResultSet. PROVIDED FILES Provided are the following files Two small SQL scripts that are needed to create the database objects. A command-line utility that can be used to generate the BPEL artifacts. A file containing properties for generating the BPEL artifacts for this sample. The BPEL artifacts that are generated using the command-line utility. A completed SOA project that is ready for immediate deployment. STEP BY STEP INSTRUCTIONS RUNNING THE PREBUILT SAMPLE Preparing the Sample Database Login to dbaccess as informix and create a new database called soainfra. Execute the following SQL statement using the Query-language tab. CREATE DATABASE soainfra WITH [BUFFERED] LOG; Specifying BUFFERED marginally enhances logging performance at the risk of not being able to re-create the last few transactions after a failure.

Adapters db-104-informixstoredprocedure

Embed Size (px)

Citation preview

Page 1: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

SAMPLE NAME: adapters-db-104-InformixStoredProcedure

COMPONENT: DB Adapter for Stored Procedures

OVERVIEW

This scenario showcases a Database Adapter partner link (Outbound Adapter Service)

that invokes a stored procedure on an Informix instance. The procedure has one input

parameter. The value of the input parameter is used in a SELECT statement that

performs a simple query to return rows from a table. The query is executed and left for

the Stored Procedure Runtime to consume as a JDBC ResultSet.

PROVIDED FILES

Provided are the following files

• Two small SQL scripts that are needed to create the database objects.

• A command-line utility that can be used to generate the BPEL artifacts.

• A file containing properties for generating the BPEL artifacts for this sample.

• The BPEL artifacts that are generated using the command-line utility.

• A completed SOA project that is ready for immediate deployment.

STEP BY STEP INSTRUCTIONS

RUNNING THE PREBUILT SAMPLE

Preparing the Sample Database

Login to dbaccess as informix and create a new database called soainfra. Execute the

following SQL statement using the Query-language tab.

CREATE DATABASE soainfra WITH [BUFFERED] LOG;

Specifying BUFFERED marginally enhances logging performance at the risk of not

being able to re-create the last few transactions after a failure.

Page 2: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

Note that if you do not specify logging then Dynamic Server creates an unlogged

database that cannot use transactions or the SQL statements that support transaction

logging.

Creating the Tables and the Stored Procedure

The tables and the stored procedure are created using the Query-language tab in

dbaccess. The DDL statements for creating the tables are CREATE TABLE emp ( ename VARCHAR(10), sal INTEGER, hiredate DATETIME YEAR TO SECOND, deptno INTEGER ); CREATE TABLE dept ( deptno INTEGER, dname VARCHAR(14), loc VARCHAR(13) );

The stored procedure is created using this statement

CREATE PROCEDURE demo(name VARCHAR(14)) RETURNING VARCHAR(10) AS ename, INTEGER AS sal, DATETIME YEAR TO SECOND AS hiredate DEFINE o_ename VARCHAR(10); DEFINE o_sal INTEGER; DEFINE o_hiredate DATETIME YEAR TO SECOND; FOREACH SELECT ename, sal, hiredate INTO o_ename, o_sal, o_hiredate FROM emp e, dept d

WHERE e.deptno = d.deptno AND d.dname = name RETURN o_ename, o_sal, o_hiredate WITH RESUME; END FOREACH END PROCEDURE;

Connect to the soainfra database as informix and execute the contents of ddl.sql and

dml.sql using the Query-language tab in dbaccess.

RUNNING THE SAMPLE

Deploying the BPEL Process

1. Create a new connection instance in the weblogic-ra.xml file.

<connection-instance> <jndi-name>eis/DB/informix</jndi-name> <connection-properties> <properties> <property> <name>xADataSourceName</name> <value></value> </property>

Page 3: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

<property> <name>dataSourceName</name> <value>jdbc/InformixDataSource</value> </property> <property> <name>platformClassName</name> <value>oracle.toplink.platform.database.InformixPlatform</value> </property> </properties> </connection-properties> </connection-instance>

2. Create a new data source for the JNDI name specified via the DatabaseConnection

property to the command-line utility and in the <jndi-name> element of the

connection instance (i.e. informix).

a. Connect to the WebLogic Server Administration Console.

b. Click the “Data Sources” link under the JDBC list item in the Services

section.

c. Enter “InformixDataSource” as the name and use the dataSourceName as

the JNDI Name.

d. Select the Informix Database Type and Oracle’s Informix Driver (Type 4)

Versions: 9.2, 9.3.

e. Select “Logging Last Resource” and uncheck the “Supports Global

Transactions” checkbox.

f. Enter the Connection Properties and click “Test Configuration”.

g. Deploy the data source to the “AdminServer” target.

3. In JDeveloper, right-click the project name and choose “Deploy” then “Deploy to

Application Server”. Accept the default deployment configuration. Check the

“Overwrite any existing composites with the same revision ID” checkbox if an

archive with the same revision ID has already been deployed.

4. Select an existing Application Server or create a connection to a new one. Choose

to deploy the archive to the AdminServer.

5. To verify that the application has been deployed successfully, click the

“Deployment” tab at the bottom of JDeveloper. This will show you the

deployment log.

6. Login to Enterprise Manager. The IfxDemo [1.0] archive will be listed in the

Deployments area.

Figure 1: Successfully Deployed Archive

TESTING THE BPEL PROCESS

Page 4: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

Click the “IfxDemo [1.0]” link. Click the “Test” button at the top of the page.

Initiate the BPEL process by entering the name of a department from the dept table in

the Request tab.

Figure 2: Initiate a Test Instance

Click the “Test Web Service” button to initiate the BPEL Process. If the test was

successful, the following output should have been generated.

Figure 3: The result of the BPEL Process execution

Remember that we modeled a one-way BPEL process so there is no response.

VERIFYING EXECUTION

Click the “Launch Message Flow Trace” link. Look at the “Trace” information.

Figure 4: Trace Results from Test Instance

Click the “DemoProcess” link. Expand “<payload>” in the Invoke activity. The

input to and output from the stored procedure invocation will be displayed.

Page 5: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

Figure 5: The input and output parameter values of the Stored Procedure execution

The value, SALES, was provided as the name of the department. One output value is

produced by the stored procedure. The RowSet captures the rows and columns of the

query in the stored procedure. There are three rows where each row consists of three

columns, ename, sal and hiredate.

BUILDING THE SAMPLE

CONFIGURING THE OUTBOUND ADAPTER SERVICE

1. Launch JDeveloper.

2. Create a new SOA Application called “IfxApp”. Create a project called

“IfxDemo” with SOA Project Technologies selected. Select “Composite with

BPEL”.

3. Create a BPEL process called “DemoProcess” and select “One Way BPEL

Process” from the list of Templates. Leave the “Expose as Composite Service”

box checked.

4. Drag a Database Adapter Service from the list of BPEL Services into the right

“Partner Links” swim lane. Enter “demo” as the Service Name.

5. Create a new Service Connection by clicking the green plus sign icon “+”. Enter

“informix” as the Connection Name. Choose “Generic JDBC”.

Page 6: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

6. Click “New” in the Generic JDBC Settings area. Click “Browse” in the Register

JDBC Driver dialog. Click “New” to create a new Library.

7. Call the Library “Informix JDBC”. Click “Add Entry” and add the Informix

JDBC driver jar files to the Class Path.

Figure 6: Create a New JDBC Library

8. Enter the Driver Class in the Register JDBC Driver dialog.

Figure 7: Register the JDBC Driver

Page 7: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

9. Enter “informix” as the username and enter a password. Enter a JDBC URL and

be sure to include the database name.

Figure 8: Create a New Service Connection

10. Click “Test Connection” to verify your connection.

11. Select “Call a Stored Procedure or Function”. Click “Browse” in the Specify

Stored Procedure dialog.

12. Enter “d%” in the Search text box and click “Search”. Select the “demo” stored

procedure.

Page 8: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

Figure 9: Search for and Select the Stored Procedure

13. Click the Source tab to view the procedure source code.

Figure 10: View the Stored Procedure Source Code

Page 9: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

14. Click “OK” then “Next”. Click “Next” in the Advanced Options page then

“Finish” to exit the wizard. Click “OK” to finish creating the Partner Link.

GENERATED BPEL ARTIFACTS

The adapter configuration wizard will generate three files. The service WSDL is

demo.wsdl. The name of the XSD will resemble “informix_demo_437.xsd”. The

number appended to the end of the name is an identifier that uniquely identifies the

stored procedure and distinguishes it from other stored procedures. This number also

appears in the generated JCA binding file, demo_db.jca, as an attribute called

“UIOverloadedProcedure”. This unique identifier is necessary to identify stored

procedures, particularly when they are overloaded.

CONFIGURING AN END TO END BPEL PROCESS

1. Configure an Invoke activity to invoke the Partner Link. Drag and drop an

Invoke activity after “receiveInput”. Right click on the Invoke and choose “Edit”.

Name the activity “Invoke”. Use the Flashlight to find and choose the “demo”

Partner Link that was just created.

2. Click “Automatically Create Input Variable” by clicking the green plus sign icon

“+”. Do the same for the Output Variable. Use the default variable names.

Choose the default “Global Variable” radio button and Click “OK” for each

variable. The “General” tab of the Invoke activity should appear as follows.

Figure 11: Configure the Invoke Activity

3. Provide a value for the Input Variable by dragging an Assign activity into the

diagram, positioning it between the receiveInput and Invoke activities. Right

click the assign and choose “Edit”. Choose “Copy Operation” from the dropdown

(the green “+”) in the “Copy Operation” tab to copy the value of the

inputVariable to the input parameter of the stored procedure.

Page 10: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

Figure 12: Copy the inputVariable to the input parameter of the Stored Procedure

Use the “General” tab to provide a name for the Assign (e.g. “Input”).

4. This completes the modeling of the BPEL Process. The diagramming between

the receiveInput and replyOutput activities should look similar to the following

Figure 13: The complete BPEL Process

5. Click the “composite.xml” tab and choose the “Design” view. The composite

should resemble

Page 11: Adapters db-104-informixstoredprocedure

Oracle SOA Suite 11g - Sample

Figure 14: Complete Composite Structure Design View