Overview of Using the WCF Service Model with the Adapter
When you consume operations that the Microsoft BizTalk Adapter for Oracle Database surfaces, your code acts either as a client or a service to the adapter. For almost all of the operations that the Oracle Database adapter surfaces, your code is the client. That is, your application invokes the operation on the adapter; for example to insert records into an Oracle table. The only operation for which your code acts as a service to the Oracle Database adapter is for the POLLINGSMT operation. In this case, the adapter sends the results of the polling query operation to your application.
In the Windows Communication Foundation (WCF) service model, the service contract that exists between a client and a service is represented as a .NET interface, and operations are represented as methods on this interface. The Oracle Database adapter and WCF provide tools that enable you to generate this interface for targeted operations from the metadata that the adapter exposes. These tools also create a WCF client class that can be used to invoke the operations exposed in the service interface. A client application can call the methods of the WCF client class to invoke operations on the adapter. To implement a service to receive the POLLINGSTMT operation from the Oracle Database adapter, you implement the interface generated for the POLLINGSTMT operation.
The following sections explain how to use the WCF service model to create client and service code for the Oracle Database adapter.
Creating and Invoking Operations on a WCF Client by Using the Oracle Database Adapter
To use the WCF service model to invoke operations on the Oracle Database adapter, you must first generate a WCF client class for the target operations. You can then create an instance of this class, a WCF client, and call its methods to perform operations on the Oracle database.
To invoke operations on the Oracle Database adapter
Generate a WCF client class and helper code. Use the Add Adapter Service Reference Visual Studio Plug-in or the ServiceModel Metadata Utility Tool (svcutil.exe) to generate a WCF client class targeted at the Oracle database artifacts with which you want to work. For more information about how to generate a WCF client, see Generating a WCF Client or a WCF Service Contract for Oracle Database Artifacts.
Create a WCF client instance by specifying a client binding. Specifying a client binding involves specifying the binding and endpoint address that the WCF client will use. You can do this either imperatively in code or declaratively in configuration. For more information about how to specify a client binding, see Specifying a Client Binding for the Oracle Database. The following code creates a WCF client that can be used to perform data manipulation language (DML) operations on an Oracle database table (/SCOTT/ACCOUNTACTIVITY). It also sets the credentials for the Oracle database. The WCF client is initialized from configuration.
SCOTTTableACCOUNTACTIVITYClient aaTableClient = new SCOTTTableACCOUNTACTIVITYClient("OracleDBBinding_SCOTT.Table.ACCOUNTACTIVITY"); aaTableClient.ClientCredentials.UserName.UserName = "SCOTT"; aaTableClient.ClientCredentials.UserName.Password = "TIGER";
Open the WCF client.
Invoke methods on the WCF client created in step 2 to perform operations on the Oracle database. The following code invokes the Select method of the WCF client to perform the following SQL SELECT query on the ACCOUNTACTIVITY table:
SELECT * FROM ACCOUNTACTIVITY.
// create a record set parameter to hold the SELECT query result set and invoke the Select operation; microsoft.lobservices.oracledb._2007._03.SCOTT.Table.ACCOUNTACTIVITY.ACCOUNTACTIVITYRECORDSELECT selectRecords; selectRecords = aaTableClient.Select("*", null);
Close the WCF client.
For more information about performing DML operations on tables and views, including the Select operation used above, see Performing Basic Insert, Update, Delete, and Select Operations by Using the WCF Service Model.
Creating and Implementing a WCF Service by Using the Oracle Database Adapter
The Oracle Database adapter can perform polling on an Oracle database table or view. This functionality lets you specify a SQL SELECT query that the adapter should execute periodically against the Oracle database. The results of this query are returned to your application through a special operation, the POLLINGSTMT operation. To receive the results of the polling query, your application must implement the service contract that the Oracle Database adapter exposes for the POLLINGSTMT operation.
To implement a service to receive the POLLINGSTMT operation, you must first generate the .NET interface (also called the WCF service contract) that represents the service contract exposed by the Oracle Database adapter for the POLLINGSTMT operation. For more information about how to do this, see Generating a WCF Client or a WCF Service Contract for Oracle Database Artifacts.
Then you implement a WCF service by implementing the generated interface. This class contains the business logic to process the POLLINGSTMT message and return a response to the adapter. Then you use a service host (System.ServiceModel.ServiceHost) to host an instance of this service. For more detailed information, see Receiving Polling-based Data-changed Messages by Using the WCF Service Model.
Other ResourcesDeveloping Applications by Using the WCF Service Model
© 2014 Microsoft Corporation. All rights reserved.