Insert, update, delete, or select operations using BizTalk Server with Oracle Database
The Microsoft BizTalk Adapter for Oracle Database surfaces a set of standard operations on Oracle database tables and views. These are called data manipulation language operations (DML) operations using which you can perform simple INSERT, UPDATE, SELECT, and DELETE statements qualified by a WHERE clause on tables and views. For more information about how the adapter supports these operations, see Insert, Update, Delete, and Select Operations on Oracle Tables and Views. For information about the structure of the SOAP message for DML operations, see Message Schemas for the Basic Insert, Update, Delete, and Select Operations on Tables and Views.
Note
To perform more complex operations, for example running a parameterized SQL SELECT query, you can use the SQLEXECUTE operation. For more information about using the SQLEXECUTE operation with BizTalk Server, see Run SQLEXECUTE Operation by Using BizTalk Server.
How to Perform Basic Operations on an Oracle Database?
Performing an operation on an Oracle database using Oracle Database adapter with BizTalk Server involves procedural tasks described in Developing BizTalk Applications. To perform Insert, Update, Delete, or Select operations on tables and views in an Oracle database, these tasks are:
Create a BizTalk project and generate schema for the operation you want to invoke on an Oracle database table or view.
Create messages in the BizTalk project for sending and receiving messages from the Oracle database.
Create an orchestration to invoke the operation on the Oracle database table or view.
Build and deploy the BizTalk project.
Configure the BizTalk application by creating physical send and receive ports.
Start the BizTalk application.
This topic provides instructions to perform these tasks.
Sample Based On This Topic
A sample, SelectAccTable, based on this topic is also provided with the BizTalk Adapter Pack. For more information, see Adapter Samples.
Generating Schema
In this topic, to demonstrate how to perform basic DML operations, we will select records from the ACCOUNTACTIVITY table under the SCOTT schema in the Oracle database. This table is created under the SCOTT schema by running the SQL scripts provided with the samples. To know more about the samples, see Adapter samples.
To demonstrate how to select records, we generate schema for Select operation for the ACCOUNTACTIVITY table under the SCOTT schema. See Get metadata for Oracle Database operations in Visual Studio for more information about how to generate schema.
Defining Messages and Message Types
The schema that you generated earlier describes the "types" required for the messages in the orchestration. A message is typically a variable, the type for which is defined by the corresponding schema. You must link the schema you generated in the first step to the messages from the Orchestration View window of the BizTalk project.
For this topic, you must create two messages—one to send a request to the Oracle database and the other to receive a response.
Perform the following steps to create messages and link them to the schema.
To create messages and link to schema
Open the Orchestration View window of the BizTalk project, if it is not already open. To do so, click View, point to Other Windows, and then click Orchestration View.
In Orchestration View, right-click Messages, and then click New Message.
Right-click the newly created message and then select Properties Window.
In the Properties pane for Message_1, do the following:
Use this To do this Identifier Type Request. Message Type From the drop-down list, expand Schemas, and then select SelectAccTable.OracleDBBindingSchema.Select, where SelectAccTable is the name of your BizTalk project. OracleDBBindingSchema is the schema generated for the Select operation on the ACCOUNTACTIVITY table. Repeat step 2 to create a new message. In the Properties pane for the new message, do the following:
Use this To do this Identifier Type Response. Message Type From the drop-down list, expand Schemas, and then select SelectAccTable.OracleDBBindingSchema.SelectResponse.
Setting up the Orchestration
You must create a BizTalk orchestration to use BizTalk Server for performing an operation on the Oracle database. In this orchestration, you drop a request message at a defined receive location. The Oracle Database adapter consumes this message and passes it on to the Oracle database via ODP. The response from the Oracle database is saved to another location. A typical orchestration for performing basic table operations on Oracle database would contain:
Send and Receive shapes to send messages to Oracle database and receive responses.
A one-way receive port to receive request messages to send to the Oracle database.
A two-way send port to send request messages to Oracle database and receive responses.
A one-way send port to send the responses from Oracle database to a folder.
A sample orchestration for the Select operation resembles the following:
Adding Message Shapes
Make sure you specify the following properties for each of the message shapes. The names listed in the Shape column are the names of the message shapes as displayed in the just-mentioned orchestration.
Shape | Shape Type | Properties |
---|---|---|
ReceiveMessage | Receive | - Set Name to ReceiveMessage - Set Activate to True |
SendMessage | Send | - Set Name to SendMessage |
ReceiveResponse | Receive | - Set Name to ReceiveResponse - Set Activate to False |
SendResponse | Send | - Set Name to SendResponse |
Adding Ports
Make sure you specify the following properties for each of the logical ports. The names listed in the Port column are the names of the ports as displayed in the orchestration.
Port | Properties |
---|---|
FileIn | - Set Identifier to FileIn - Set Type to FileInPort - Set Communication Pattern to One-Way - Set Communication Direction to Receive |
LOBPort | - Set Identifier to LOBPort - Set Type to LOBPortType - Set Communication Pattern to Request-Response - Set Communication Direction to Send-Receive |
SaveResponse | - Set Identifier to SaveResponse - Set Type to SaveResponseType - Set Communication Pattern to One-Way - Set Communication Direction to Send |
Specify Messages for Action Shapes, and Connect Them to Ports
The following table specifies the properties and their values that you should set to specify messages for action shapes and to link the messages to the ports. The names listed in the Shape column are the names of the message shapes as displayed in the orchestration mentioned earlier.
Shape | Properties |
---|---|
ReceiveMessage | - Set Message to Request - Set Operation to FileIn.Select.Request |
SendMessage | - Set Message to Request - Set Operation to LOBPort.Select.Request |
ReceiveResponse | - Set Message to Response - Set Operation to LOBPort.Select.Response |
SendResponse | - Set Message to Response - Set Operation to SaveResponse.Select.Request |
After you have specified these properties, the message shapes and ports are connected and your orchestration is complete.
You must now build the BizTalk solution and deploy it to a BizTalk Server. For more information, see Building and Running Orchestrations.
Configuring the BizTalk Application
After you have deployed the BizTalk project, the orchestration you created earlier is listed under the Orchestrations pane in the BizTalk Server Administration console. You must use the BizTalk Server Administration console to configure the application. For a walkthrough, see Walkthrough: Deploying a Basic BizTalk Application.
Configuring an application involves:
Selecting a host for the application.
Mapping the ports that you created in your orchestration to physical ports in the BizTalk Server Administration console. For this orchestration you must:
Define a location on the hard disk and a corresponding file port where you will drop a request message. The BizTalk orchestration will consume the request message and send it to the Oracle database.
Define a location on the hard disk and a corresponding file port where the BizTalk orchestration will drop the response message containing the response from the Oracle database.
Define a physical WCF-Custom or WCF-OracleDB send port to send messages to the Oracle database. You must also specify the action in the send port. For information about how to create WCF-Custom or WCF-OracleDB ports, see Manually configure a physical port binding to the Oracle Database Adapter.
Note
Generating the schema using the Consume Adapter Service BizTalk Project Add-in also creates a binding file that contains information about the ports and the actions to be set for those ports. You can import this binding file from the BizTalk Server Administration console to create send ports (for outbound calls) or receive ports (for inbound calls). For more information, see Configure a physical port binding using a port binding file to Oracle Database.
Starting the Application
You must start the BizTalk application for selecting records from an Oracle database table. For instructions on starting a BizTalk application, see How to Start an Orchestration.
At this stage, make sure:
The FILE receive port to receive request messages for the orchestration is running.
The FILE send port to receive the response messages from the orchestration is running.
The WCF-Custom or WCF-OracleDB send port to send messages to the Oracle database is running.
The BizTalk orchestration for the operation is running.
Executing the Operation
After you run the application, you must drop a request message to the FILE receive location. The schema for the request message must conform to the schema for the Select operation you generated earlier. For example, the request message to select records from ACCOUNTACTIVITY table having the ACCOUNT field equal to 100001 is:
<Select xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/ACCOUNTACTIVITY">
<COLUMN_NAMES>*</COLUMN_NAMES>
<FILTER>ACCOUNT=100001</FILTER>
</Select>
See Message Schemas for the Basic Insert, Update, Delete, and Select Operations on Tables and Views for more information about the request message schema for performing basic DML operations on Oracle database tables and views using the Oracle Database adapter.
The orchestration consumes the message and sends it to the Oracle database. The response from the Oracle database is saved at the other FILE location defined as part of the orchestration. For example, the response from Oracle database for the above request message is:
<?xml version="1.0" encoding="utf-8" ?>
<SelectResponse xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/ACCOUNTACTIVITY">
<SelectResult>
<ACCOUNTACTIVITYRECORDSELECT>
<TID>1</TID>
<ACCOUNT>100001</ACCOUNT>
<AMOUNT>500</AMOUNT>
<DESCRIPTION />
<TRANSDATE>2007-10-16T16:58:44</TRANSDATE>
<PROCESSED>n</PROCESSED>
</ACCOUNTACTIVITYRECORDSELECT>
<ACCOUNTACTIVITYRECORDSELECT>
….
….
<ACCOUNTACTIVITYRECORDSELECT>
….
….
</SelectResult>
</SelectResponse>
Possible Exceptions
For information about the exceptions you might encounter while performing a DML operation using BizTalk Server, see Exceptions and error handling.
Best Practices
After you have deployed and configured the BizTalk project, you can export configuration settings to an XML file called the bindings file. Once you generate a bindings file, you can import the configuration settings from the file so that you do not need to create the send ports, receive ports, etc. for the same orchestration. For more information about binding files, see Reuse Oracle Database Adapter bindings.