Tutorial: Using the BizTalk Adapter for Oracle to Insert Data Into an Oracle Database
The BizTalk Adapter for Oracle can be used to update an Oracle table with information received from a trading partner or internal application. This walkthrough describes an SDK sample that illustrates this functionality.
- The appropriate Oracle client must be installed on your BizTalk Server. See BizTalk Adapter for Oracle Database System Requirements for more information on the supported versions of the Oracle client.
- It is recommended that you install the Oracle Enterprise Manager or the Oracle SQL*Plus utility on the BizTalk Server so that you can verify the results of the walkthrough. These tools can be installed with the Oracle client.
- This tutorial requires that you have an Oracle Database with the SCOTT schema installed with the table EMP. The scott.sql script in a standard Oracle Database installation that creates the SCOTT schema can be found in the <ORACLE_HOME>\rdbms\admin\ directory and can be executed using the Oracle SQL*Plus utility. For information about using the SQL*Plus utility see the Oracle documentation.
Note The SCOTT schema is installed with the table EMP by default when you create a new Oracle database. - Visual Studio 2005 must be installed in order to build and deploy the sample.
The sample is located in the following folder:
\Program Files\Microsoft BizTalk Adapters for Enterprise Applications\Oracle(r) Database\Sdk\OracleDBOneWaySend
The following table shows the files in this sample and describes their purpose.
Runtime Project Filename | Runtime Project File Description |
---|---|
OneWaySend.btproj,
OneWaySend.sln
|
Project and solution files for the application.
|
EMPService.xsd,
EMPService_1.xsd,
EMPService_2.xsd
|
Schema files for the application.
Note
The adapter schema files in the project were originally created using the Add Adapter Metadata Wizard. For more information on the Add Adapter Metadata Wizard see the topic "How to Add Adapter Metadata to a BizTalk Project" in the BizTalk Server 2006 documentation.
|
OracleDBOneWaySend.odx
|
The orchestration used by the application.
|
OracleDBOneWaySend.snk
|
The strong naming key file.
|
- Use the Oracle Enterprise Manager or the Oracle SQL*Plus utility to create the EMP table on an Oracle database if this table does not already exist. The scott.sql script in a standard Oracle database installation that creates the SCOTT schema can be found in the <ORACLE_HOME>\rdbms\admin\ directory and can be executed using the Oracle SQL*Plus utility. For information about using the SQL*Plus utility see the Oracle documentation.
- Launch the BizTalk Server 2006 Administration Console. Click Start, Programs, Microsoft BizTalk Server 2006, BizTalk Server Administration.
- In the BizTalk Server 2006 Administration Console, expand BizTalk Server 2006 Administration, expand BizTalk Group, expand Platform Settings, and then click Adapters.
- Right-click Adapters and point to New, Adapter… to display the Adapter Properties dialog.
- Enter a value for the Name field, for example OracleDb.
- Select Oracle(r) Database from the list of adapters available in the Adapter dropdown and click OK.
- Launch the ODBC Data Source Administrator. Click Start, Settings, Control Panel, Administrative Tools, Data Sources (ODBC).
- In the ODBC Data Source Administrator click the System DSN tab and click the Add button.
- Select the Oracle driver that was installed with the Oracle client from the list of available drivers. For example, if you installed the Oracle database 10.2.0.1 client, the name of the driver might be Oracle in Ora10201Client.
- Click Finish to display the Oracle ODBC Driver Configuration dialog.
- Enter a value for the Data Source Name field, this name must match the named defined as the TNS Service Name configured for the Oracle database, for example OraServer.BizTalk. For information about the TNS Service Name, see the Oracle documentation.
- Enter the appropriate value for the TNS Service Name field; this entry must match the name defined for the TNS Service Name configured for the Oracle database, for example OraServer.BizTalk.
- Enter the value scott into the User ID field. This user account is associated with the EMP database by default.
- Click the Test Connection button to verify the connection to the database. When prompted for credentials enter the appropriate credentials for the EMP table into the Password field and click OK. A dialog box will be displayed indicating whether the test succeeded or failed. This connection must succeed in order to use the BizTalk Adapter for Oracle. If the test connection fails there should be information displayed in the dialog box that indicates the reason for the failure.
Note The default password for the EMP table associated with the scott schema is tiger.
- In the BizTalk Server 2006 Administration Console, expand BizTalk Server 2006 Administration, expand BizTalk Group, expand Applications, expand BizTalk Application 1, and click Send Ports.
- Right-click Send Ports and point to New, Static One-Way Send Port… to display the Send Port Properties dialog.
- Enter a value for the Name field, for example OracleDBOneWaySP.
- Select the Oracle database adapter from the list of available adapters in the Type dropdown box and click the Configure button to display the adapter Transport Properties dialog box.
Note This value is the name that was specified when the Oracle database adapter was created in the BizTalk Server 2006 Administration Console. - Enter the following values for the Adapter Required Properties:
Property Value PasswordPassword associated with the scott account. By default this password is tiger.PATHPath to the BIN directory installed with the Oracle client, for example C:\Oracle\product\10.2.0\client_1\BINService nameName defined for the System DSN that is used to connect to the Oracle database. This should match the name defined for theTNS Service Name configured for the Oracle database, for example OraServer.BizTalk.User namescott - Click OK.
- Select the XML Transmit pipeline from the list of pipelines available in the Send pipeline dropdown and click OK.
- Right-click the send port and click Start to enlist and start the send port.
- In the BizTalk Server 2006 Administration Console, expand BizTalk Server 2006 Administration, expand BizTalk Group, expand Applications, expand BizTalk Application 1, and click Receive Ports.
- Right-click the Receive Ports folder and then click New, One-Way Receive Port... to display the Receive Port Properties dialog.
- Enter a value for the Name field, for example OracleDBOneWayFileRP, and click OK.
- Create a folder to be monitored by the file receive location, for example C:\Filesource.
- Right-click the new receive port and then click New, Receive Location… to display the Receive Location Properties dialog.
- Enter a value for the Name field, for example OracleDBOneWayFileRL.
- Select FILE from the list of available adapters in the Type dropdown box and click the Configure button to display the adapter Transport Properties dialog box.
- Enter the location of the folder that you created earlier for the Receive Folder property and click OK.
- Select XMLReceive from the list of available pipelines in the Receive pipeline dropdown box and click OK.
- Right-click the receive location and click Enable.
- Launch Visual Studio 2005 and open OneWaySend.sln. Click File, Open, Project/Solution… to display the Open Project dialog.
- Browse to the OneWaySend.sln file, click to select this file and click Open to open the solution that contains the sample project.
- Click the View menu and select Solution Explorer to display the Solution Explorer.
- Double-click the EMPService_1.xsd file in the Solution Explorer to open it.
- Right-click the Schema node of EMPService_1.xsd and select the Properties menu option to display the properties for the schema.
- Edit the Target Namespace property to use the appropriate values for the adapter name and the System DSN/TNS Service name, for example the Target Namespace property should read as follows:
http://schemas.microsoft.com/[OracleDb://OraServer.BizTalk/SCOTT/Tables/EMP]
Where OraServer.BizTalk is the name defined for the System DSN and the TNS Service Name configured for the Oracle database.Important If the configured value for Target Namespace does not match the namespace specified in the input document instance then a routing failure will occur when the input document instance is processed by BizTalk Server.
- Right-click the Schema node of EMPService_1.xsd and select the Properties menu option to display the properties for the schema.
- Select Insert from the list of available nodes in the Root Reference dropdown box. This should be done so that when you generate a sample document instance it will be generated from the Insert node of the schema.
- Right-click EMPService_1.xsd in Solution Explorer and click Properties to display the Property Pages dialog.
- Click to select the Output Instance Filename option under the General section of the Property Pages dialog.
- Click the ellipses button (…) to display the Select Output File dialog.
- Specify a folder and name for the output file instance, for example C:\instance.xml and click Save, and then click OK.
Note Do not specify the location of the folder that was specified for the file receive location here. - Right-click EMPService_1.xsd in Solution Explorer and click Generate Instance to generate a document instance in the specified location.
- Right-click the Schema node of EMPService_1.xsd and select the Properties menu option to display the properties for the schema.
- Select (Default) from the list of available nodes in the Root Reference dropdown box.
- Open the generated document instance in a text editor such as Notepad and edit the contents of the document instance to more closely approximate a sample employee record. For example the record below describes an employee named Steve with the job title of Architect:
<ns0:Insert xmlns:ns0="http://schemas.microsoft.com/[OracleDb://OraServer.BizTalk/SCOTT/Tables/EMP]"> <ns0:Rows> <ns0:Record> <ns0:EMPNO>8000</ns0:EMPNO> <ns0:ENAME>Steve</ns0:ENAME> <ns0:JOB>Architect</ns0:JOB> <ns0:MGR>7839</ns0:MGR> <ns0:HIREDATE>1999-05-31T13:20:00.000-05:00</ns0:HIREDATE> <ns0:SAL>5000</ns0:SAL> <ns0:COMM>0</ns0:COMM> <ns0:DEPTNO>10</ns0:DEPTNO> </ns0:Record> </ns0:Rows> </ns0:Insert>
Note In the example above, OraServer.BizTalk is a placeholder for the name of the System DSN as viewed in the ODBC Data Source Administrator. - Save the modified document instance.
- Right-click the OneWaySend project in Solution Explorer and click Properties to display the Property Pages dialog for the project.
- Click the Deployment option under Configuration Properties in the left pane of the Property Pages dialog.
- Enter the appropriate values for the Server property and the Configuration Database property under BizTalk Group in the right pane of the Property Pages dialog and click OK.
- Right-click the OneWaySend project in Solution Explorer and click Deploy to build the project and deploy the assembly to the BizTalk Server configuration database.
- In the BizTalk Server 2006 Administration Console, expand BizTalk Server 2006 Administration, expand BizTalk Group, expand Applications, expand BizTalk Application 1, and click Orchestrations.
- Click the Refresh button in the MMC toolbar or press the F5 key on your keyboard to refresh the BizTalk Server Administration Console view.
- Double-click the orchestration to display the Orchestration Properties dialog.
- Click Bindings in the left pane of the dialog to display the Bindings options for the orchestration.
- Specify the appropriate values for the binding options, for example:
Parameter Value HostBizTalkServerApplicationFileReceivePortOracleDBOneWayFileRPOracleDBSendPortOracleDBOneWaySP - Click OK.
The following sequence of events occurs if the document instance is processed successfully:
- The File adapter retrieves the file from the folder and publishes it to the MessageBox as a BizTalk message.
- The orchestration subscribes to this published message so the BizTalk Messaging Engine will activate an instance of the orchestration and send the message to the orchestration instance.
- The orchestration instance processes the message using the logic specified in the orchestration and publishes the message back to the MessageBox.
- The Oracle send port subscribes to this published message and so the BizTalk Messaging Engine sends the message to the Oracle send port.
- The send port hands the message to the BizTalk Adapter for Oracle.
- The BizTalk Adapter for Oracle executes an INSERT statement to update the target table with the data in the message.
No comments:
Post a Comment