MSDN Library

Invoking a Function by Using the WCF Channel Model

This section demonstrates how to execute a function in an Oracle database using the channel created in Creating a Channel.

Executing a Function Using the Channel

You can execute a function on an Oracle database by passing an XML message to Microsoft BizTalk Adapter for Oracle Database. The input XML resembles the following:

<CREATE_ACCOUNT xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG" xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG/CREATE_ACCOUNT">
  <REC xmlns="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG">

The following code excerpt demonstrates how to execute a function in an Oracle database using a channel.

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.ServiceModel;
using System.ServiceModel.Channels;
using Microsoft.ServiceModel.Adapters;
using Microsoft.Adapters.OracleDB;
namespace OraclePackageChannel
    class Program
        static void Main(string[] args)
            // Create Endpoint
            EndpointAddress address = new EndpointAddress("oracledb:// ADAPTER");
            // Create Binding
            OracleDBBinding binding = new OracleDBBinding();
            // Create Channel Factory
            ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>(binding, address);
            factory.Credentials.UserName.UserName = "SCOTT";
            factory.Credentials.UserName.Password = "TIGER";
            // Create Request Channel
            IRequestChannel channel = factory.CreateChannel();
            // Send Request
            System.Xml.XmlReader readerIn = System.Xml.XmlReader.Create("Create_Account.xml");
            Message messageIn = Message.CreateMessage(MessageVersion.Default, "http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Package/ACCOUNT_PKG/CREATE_ACCOUNT", readerIn);
            Message messageOut = channel.Request(messageIn);
            // Get Response XML
            XmlReader readerOut = messageOut.GetReaderAtBodyContents();
            // Get Employee ID
            XmlDocument doc = new XmlDocument();

See Also

© 2014 Microsoft Corporation. All rights reserved.
© 2016 Microsoft