Muokkaa

Jaa


Get Metadata Using WS-Metadata Exchange in Oracle Database

As a Windows Communication Foundation (WCF) custom binding, the Microsoft BizTalk Adapter for Oracle Database exposes a WS-Metadata Exchange (MEX) endpoint that you can use to retrieve metadata for specific operations from the Microsoft BizTalk Adapter for Oracle Database.

WCF provides a rich infrastructure for exporting, publishing, retrieving and importing metadata about a service. WCF services, like the adapter, use metadata to describe how to interact with the service endpoints so that tools, like svcutil.exe, can automatically generate client code for consuming the service. WCF represents the metadata for a service as an instance of the MetadataSet type, which is strongly tied to the metadata serialization format defined in WS-Metadata Exchange (MEX). You can create a MetadataSet for targeted operations on the adapter by using a MetadataExchangeClient.

WCF support for metadata exchange is an expansive topic and beyond the scope of this documentation. For more information about support for metadata in WCF, see Metadata. For a particularly good description of the architecture, classes, and namespaces that WCF exposes for metadata, see Metadata Architecture Overview. You should familiarize yourself with the content related to retrieving metadata from a WCF service in these WCF topics before proceeding.

The following topics contain information about how to use a MetadataExchangeClient to retrieve metadata from the Oracle Database adapter.

Using a MetadataExchangeClient to Retrieve Metadata

To use a MetadataExchangeClient you must specify a connection URI and a binding (OracleDBBinding). The connection URI identifies the operations for which you want to retrieve metadata.

The following sections contain information about how to specify the connection URI, important binding properties, and how to use a MetadataExchangeClient to retrieve metadata from the adapter.

The Connection URI

To use the MetadataExchangeClient you must supply an Oracle connection URI that specifies a MEX endpoint and the operation or operations for which you want to retrieve metadata. You specify a MEX endpoint and target operations in the connection URI in the following manner:

  • You must include the "wsdl" parameter in the query string. If it is the first parameter in the query string, it is specified just after the question mark (?). If it is not the first parameter, it should be preceded with an ampersand (&).

  • You must follow the "wsdl" parameter by one or more "op" parameters. Each "op" parameter is preceded by an ampersand (&) and specifies the message action (node ID) of a target operation.

    For example, the following connection URI targets the Insert and Delete operations for the SCOTT.EMP table. The "wsdl" and "op" parameters are highlighted.

"oracledb://ADAPTER?wsdl&op=http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/EMP/Insert&op=http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/EMP/Delete"  

Note

If you want to modify the namespace generated for the POLLINGSTMT operation you should specify a PollingId parameter in the query string.

How you pass this connection URI to the MetadataExchangeClient depends on which of the overloaded methods you use to create the client and retrieve metadata from the adapter.

For more information about the Oracle connection URI, see Create the Oracle Database connection URI.

Binding Properties

When you create the MetadataExchangeClient, you must specify an OracleDBBinding.

There are several binding properties that affect how the adapter generates metadata. These properties are:

  • EnableSafeTyping

  • UseSchemaInNamespace

  • PollingStatement

Important

If you want to retrieve metadata for the POLLINGSTMT operation you must set the PollingStatement binding property.

You should ensure that these binding properties are set to the values required for your application before you invoke the GetMetadata method on the MetadataExchangeClient. For more information about the Oracle Database adapter binding properties, see Read about the Oracle Database adapter binding properties.

Example

The following example uses a MetadataExchangeClient to create a service description (WSDL document) for the Insert, Update, Delete, and Select operations on the SCOTT.EMP table. The WSDL is saved to a file, EmpOperations.wsdl.

using System;  
using System.Collections.Generic;  
using System.Text;  
using System.Collections.ObjectModel;  
  
// Needed for WCF and Oracle Adapter  
using System.ServiceModel;  
using Microsoft.ServiceModel.Channels;  
using Microsoft.Adapters.OracleDB;  
  
// Needced for MetadataExchangeClient class  
using System.ServiceModel.Description;  
// Needed for ServiceDescription class  
using System.Web.Services;  
  
namespace OracleMetadataExchange  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            //create a binding  
            OracleDBBinding binding = new OracleDBBinding();  
  
            //create a metadata exchange client that will retrieve metadata according to the WS-MEX standard  
            MetadataExchangeClient client = new MetadataExchangeClient(binding);  
            client.SoapCredentials.UserName.UserName = "SCOTT";  
            client.SoapCredentials.UserName.Password = "TIGER";  
  
            //set up an endpoint address and specifies the operations for which we want metadata  
            string connectionUri = "oracledb://ADAPTER?wsdl"  
                + "&op="  
                + "http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/EMP/Insert"  
                + "&op="  
                + "http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/EMP/Update"  
                + "&op="  
                + "http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/EMP/Delete"  
                + "&op="  
                + "http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/EMP/Select";  
  
            EndpointAddress address = new EndpointAddress(connectionUri);  
  
            //get the metadata  
            MetadataSet ms = client.GetMetadata(address);  
  
            // Check for the metadata set size   
            Collection<MetadataSection> documentCollection = ms.MetadataSections;  
            if (documentCollection != null && documentCollection.Count > 0)  
            {  
                //get the wsdl from the metadata set  
                System.Web.Services.Description.ServiceDescription wsdl = (System.Web.Services.Description.ServiceDescription)documentCollection[0].Metadata;  
  
                //save the wsdl to a file  
                wsdl.Write("EmpOperations.wsdl");  
  
            }  
  
        }  
    }  
}  

See Also

Get Metadata Programmatically from the Oracle Database