Export (0) Print
Expand All

Invoking Functions and Procedures by Using BizTalk Server

Adapter clients can invoke functions and procedures in an Oracle database by using the Oracle Database adapter with BizTalk Server. The Oracle Database adapter surfaces procedures, functions, and packages as operations. The Oracle Database adapter also enables adapter clients to invoke:

For more information about working with functions and stored procedures by using the Oracle Database adapter, see Operations on Functions and Stored Procedures. For information about the structure of the SOAP message for invoking functions and procedures, see Message Schemas for Functions and Procedures.

Performing an operation on an Oracle database using Oracle Database adapter with BizTalk Server involves procedural tasks described in Building Blocks for Developing BizTalk Applications. To invoke a function in an Oracle database, these tasks are:

  1. Create a BizTalk project and generate schema for the function you want to invoke in an Oracle database.

  2. Create messages in the BizTalk project for sending and receiving messages from the Oracle database.

  3. Create an orchestration to invoke the function in the Oracle database.

  4. Build and deploy the BizTalk project.

  5. Configure the BizTalk application by creating physical send and receive ports.

  6. Start the BizTalk application.

This topic provides instructions to perform these tasks.

A sample, InvokeFunction, based on this topic is also provided with the BizTalk Adapter Pack. For more information, see Samples.

In this topic, to demonstrate how to invoke a function, we will invoke the CREATE_ACCOUNT function under the SCOTT\Package\ACCOUNT_PKG schema. This package is created under the SCOTT schema by running the SQL scripts provided with the samples. The CREATE_ACCOUNT function takes account and addresses information as inputs and creates records in the ACCOUNT and CUSTOMER tables. IF the record already exists, the function returns zero; otherwise, the function returns the account ID. To know more about the samples and the SQL scripts, see Samples.

To invoke the CREATE_ACCOUNT function, we must generate schema for the same function under the SCOTT\Package\ACCOUNT_PKG schema. See Retrieving Metadata for Oracle Operations in Visual Studio for more information about how to generate schema.

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:

  1. 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.

  2. In Orchestration View, right-click Messages, and then click New Message.

  3. Right-click the newly created message, and then select Properties Window.

  4. 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 InvokeFunction.OracleDBBindingSchema.CREATE_ACCOUNT, where InvokeFunction is the name of your BizTalk project. OracleDBBindingSchema is the schema generated for the CREATE_ACCOUNT function.

  5. Repeat the previous step 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 InvokeFunction.OracleDBBindingSchema.CREATE_ACCOUNTResponse.

You must create a BizTalk orchestration to use BizTalk Server for invoking functions on an 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 invoking functions and procedures in an 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 resembles the following:

Orchestration to invoke a function in Oracle

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 FileInType

  • 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

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.Function.Request

SendMessage

  • Set Message to Request

  • Set Operation to LOBPort.Function.Request

ReceiveResponse

  • Set Message to Response

  • Set Operation to LOBPort.Function.Response

SendResponse

  • Set Message to Response

  • Set Operation to SaveResponse.Function.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 http://go.microsoft.com/fwlink/?LinkId=102359.

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 more information about configuring an application, see http://go.microsoft.com/fwlink/?LinkID=196961.

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 Configuring a Physical Port Binding to the Oracle Database Adapter.

      Dd787896.note(en-us,BTS.70).gifNote
      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 Configuring a Physical Port Binding by Using a Port Binding File.

You must start the BizTalk application for invoking a function in an Oracle database table. For instructions on starting a BizTalk application, see http://go.microsoft.com/fwlink/?LinkId=102387.

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.

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 function you generated earlier. See Message Schemas for Functions and Procedures for more information about the request message schema for invoking functions using the Oracle Database adapter.

For example, the request message to invoke the CREATE_ACCOUNT function is:

<CREATE_ACCOUNT xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG">
  <ACCT>
    <ACCTID xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG/CREATE_ACCOUNT"></ACCTID>
    <NAME xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG/CREATE_ACCOUNT">John Smith</NAME>
    <BALANCE xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG/CREATE_ACCOUNT">10000</BALANCE>
  </ACCT>
  <ADDR>
    <STREET xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG/CREATE_ACCOUNT">BelRed Road</STREET>
    <CITY xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG/CREATE_ACCOUNT">Redmond</CITY>
    <STATE xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG/CREATE_ACCOUNT">WA</STATE>
  </ADDR>
</CREATE_ACCOUNT>

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"?>
<CREATE_ACCOUNTResponse xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG">
<CREATE_ACCOUNTResult>[ID]</CREATE_ACCOUNTResult>
</CREATE_ACCOUNTResponse>

Where, [ID] is the ID of the account created by the function.

For information about the exceptions you might encounter while invoking functions and procedures using BizTalk Server, see Exceptions and Error Handling.

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 Reusing Adapter Bindings.

Show:
© 2014 Microsoft