System.Runtime.Remoting.Channels.Http.HttpChannel Class

Assembly: System.Runtime.Remoting.dll
Namespace: System.Runtime.Remoting.Channels.Http
Summary
Provides an implementation for a sender-receiver channel that uses the HTTP protocol to transmit messages.
C# Syntax:
public class HttpChannel : BaseChannelWithProperties, IChannelReceiver, IChannel, IChannelSender, IChannelReceiverHook
Remarks
The HttpChannel class is a combined channel, which combines the HttpServerChannel and HttpClientChannel for convenience. The HttpChannel transports messages to and from remote objects using the SOAP protocol. All outbound messages are passed through the SOAP formatter, where the message is changed into XML and serialized, and the required SOAP headers are added to the stream. The binary formatter can also be specified, which results in a binary data stream. The data stream is then transported to the URI using the HTTP protocol. For inbound messages the process is reversed.

Channels transport messages between applications across remoting boundaries (for example application domains, processes, and machines). These crossings include both inbound and outbound. The current channel listens on an endpoint for inbound messages and sends the outbound messages to the endpoint. The HttpChannel converts the messages sent along it to and from the XML format, receiving and sending them using the HTTP protocol.

On the client side, messages are handed off to the client channel sink chain after they traverse the client Context chain. The first channel sink is typically an IClientFormatterSink which serializes the message into a stream that is passed down the channel sink chain to the client transport sink. The client transport sink then writes this stream out to the wire.

On the server side, the server transport sink reads requests off of the wire and passes the request stream to the server channel sink chain. The server formatter sink at the end of this chain will deserialize the request into a message. It will then hand this message off to the Remoting infrastructure which will dispatch it to the server Context chain.

IChannel implementations use channel configuration properties to configure the channel at run time. Channel properties can be specified in a configuration file, or programmatically, inside of an IDictionary. In a configuration file all values are represented by strings, but when building a property IDictionary programatically, value types can be specified with their native values or with strings.

The following table shows the channel configuration properties that can be specified for the current channel.



Property Description
name Indicates the name of the channel. This property is used to retrieve a specific channel when calling ChannelServices.GetChannel . If this property is not set, the system defaults to "http". If you want to register more than one HttpChannel , each must have a unique name. Set this property to the String.Empty string ("") if you want to ignore names, but avoid naming collisions. The system will allow any number of channels with the String.Empty name.
priority An integer representing the priority assigned to this channel. Higher numbers indicate a higher chance of being chosen to connect first. The default priority is 1, and negative numbers are allowed.
clientConnectionLimit An integer indicating how many connections can be simultaneously opened to a given server. The default is 2.
proxyName The name of the proxy computer.
proxyPort An integer specifying the proxy port.
port An integer specifying the port on which the channel will listen.
supressChannelData true or false . Specifies that the channel will not contribute to the HttpChannel.ChannelData .
useIpAddress true or false . Specifies whether the channel shall use the IP address in the publication URL instead of the computer name.
listen true or false . Specifies whether to allow activation to hook into the outside listener service.
bindTo An IP address resolving to the current computer that specifies which NIC to bind the current channel to.
machineName A string that specifies the machine name used with the current channel. Overrides the useIpAddress configuration property and the machine name channel data.
See also:
System.Runtime.Remoting.Channels.Http Namespace | SoapFormatter | BinaryFormatter | MSDN: channelformatterconfigurationproperties

System.Runtime.Remoting.Channels.Http.HttpChannel Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the HttpChannel class, activating the client and server channels with default values.
ctor #2 Overloaded:
.ctor(int port)

Initializes a new instance of the HttpChannel class, activating the underlying HttpServerChannel on the specified port.
ctor #3 Overloaded:
.ctor(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)

Initializes a new instance of the HttpChannel class with the given channel properties and specified IClientChannelSinkProvider and IServerChannelSinkProvider.
Public Properties
ChannelData Read-only

Gets the channel-specific data.
ChannelName Read-only

Gets the name of the current channel.
ChannelPriority Read-only

Returns the priority of the current channel.
ChannelScheme Read-only

Gets the type of listener to hook into (for example "http").
ChannelSinkChain Read-only

Gets the channel sink chain that the current channel is using.
Count
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
Read-only

See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Count


Gets the number of properties associated with the current channel object.
IsFixedSize
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
Read-only

See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.IsFixedSize


Gets a Boolean value indicating whether the number of properties that can be entered into the current channel object is fixed.
IsReadOnly
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
Read-only

See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.IsReadOnly


Gets a Boolean value indicating whether the collection of properties in the current channel object is read-only.
IsSynchronized
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
Read-only

See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.IsSynchronized


Gets a value indicating whether the current dictionary of channel object properties is synchronized.
Item Read-write

Overridden:
Gets or sets a channel property associated with the specified key.
Keys Read-only

Overridden:
Gets an ICollection of keys with which the channel properties are associated.
Properties Read-only

Overridden:
Gets an IDictionary of the channel properties associated with the current channel.
SyncRoot
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
Read-only

See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.SyncRoot


Gets an object that is used to synchronize access to the BaseChannelObjectWithProperties.
Values
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
Read-only

See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Values


Gets an ICollection of the values of the properties associated with the current channel object.
WantsToListen Read-write

Gets a Boolean value indicating whether the current instance wants to be hooked into the outside listener service.
Public Methods
Add
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Add


The current method must not be implemented because it does not apply to the way IDictionary is being used in this case, and because BaseChannelObjectWithProperties.IsFixedSize returns true.
AddHookChannelUri Adds a URI on which the channel hook should listen.
Clear
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Clear


The current method must not be implemented because it does not apply to the way IDictionary is being used in this case, and because BaseChannelObjectWithProperties.IsFixedSize returns true.
Contains
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Contains


Returns a Boolean value indicating whether the current channel object contains a property associated with the specified key.
CopyTo
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.CopyTo


The current method is not supported by the BaseChannelObjectWithProperties.
CreateMessageSink Returns a channel message sink that delivers messages to the specified URL or channel data object.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetEnumerator
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.GetEnumerator


Returns an IDictionaryEnumerator that enumerates over all the properties associated with the current channel object.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
GetUrlsForUri Returns an array of all the URLs for an object with the specified URI, hosted on the current HttpChannel.
Parse Extracts the channel URI and the remote well known object URI from the specified URL.
Remove
(inherited from System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties)
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Remove


The current method must not be implemented because it does not apply to the way IDictionary is being used in this case, and because BaseChannelObjectWithProperties.IsFixedSize returns true.
StartListening Instructs the current channel to start listening for requests.
StopListening Instructs the current channel to stop listening for requests.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Fields
SinksWithProperties
(inherited from System.Runtime.Remoting.Channels.BaseChannelWithProperties)
See base class member description: System.Runtime.Remoting.Channels.BaseChannelWithProperties.SinksWithProperties


Indicates the top channel sink in the channel sink stack.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Runtime.Remoting.Channels.Http.HttpChannel Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the HttpChannel class, activating the client and server channels with default values.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public HttpChannel();
Remarks
The default constructor initializes all fields to their default values. If the default constructor is used, the channel functions only as a client channel, and does not listen on any ports.

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the HttpChannel class, activating the underlying HttpServerChannel on the specified port.
C# Syntax:
public HttpChannel(
   int port
);
Parameters:

port

The port on which to activate the underlying HttpServerChannel.

Example

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the HttpChannel class with the given channel properties and specified IClientChannelSinkProvider and IServerChannelSinkProvider.
C# Syntax:
public HttpChannel(
   IDictionary properties,
   IClientChannelSinkProvider clientSinkProvider,
   IServerChannelSinkProvider serverSinkProvider
);
Parameters:

properties

The channel properties with which the new instance of HttpChannel should be initialized.

clientSinkProvider

The IClientChannelSinkProvider that creates the client channel sinks for the underlying HttpClientChannel through which remoting messages flow through.

serverSinkProvider

The IServerChannelSinkProvider that creates server channel sinks for the underlying HttpServerChannel through which remoting messages flow through.

Exceptions
Exception Type Condition
ArgumentException The provided channel properties are not in the correct format.
Remarks
Channel sinks provide a plug-in point that allows access to the underlying messages flowing through the channel as well as the stream used by the transport mechanism to send messages to a remote object. Channel sinks are also responsible for transporting messages between the client and the server. Channel sinks are linked together in a chain, and all channel messages flow through this chain of sinks before the message is finally serialized and transported.

When the IClientChannelSinkProvider.CreateSink method is called on a sink provider, it should create its own channel sink, forward the CreateSink call to the next sink provider in the chain, and ensure that the next sink and the current one are linked together. The provider then returns its sink to the caller. Channel sinks are responsible for forwarding all calls made on them to the next sink in the chain.



Note Channel properties are used to configure the channel at run time. For a list of possible channel properties and an example, see the conceptual topic at MSDN: channelformatterconfigurationproperties.
Example
The following example demonstrates initialization of an HttpChannel class with an IDictionary of configuration properties, an IClientChannelSinkProvider, and an IServerChannelSinkProvider.
        ListDictionary channelProperties = new ListDictionary();

        channelProperties.Add("port", 9000);
        
        HttpChannel channel = new HttpChannel(channelProperties,
                                              new SoapClientFormatterSinkProvider(),
                                              new SoapServerFormatterSinkProvider());

        ChannelServices.RegisterChannel(channel);

        RemotingConfiguration.RegisterWellKnownServiceType(typeof(SampleService), 
							"MySampleService/SampleService.soap",
							WellKnownObjectMode.Singleton);
        
        Console.WriteLine("** Press enter to end the server process. **");
        Console.ReadLine();

    
See also:
MSDN: channelformatterconfigurationproperties

Return to top


Field: SinksWithProperties
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelWithProperties.SinksWithProperties

Summary
Indicates the top channel sink in the channel sink stack.
C# Syntax:
protected IChannelSinkBase SinksWithProperties;
Remarks
Channel sinks provide a plug-in point that allows access to the underlying messages flowing through the channel as well as the stream used by the transport mechanism to send messages to a remote object. Channel sinks are linked together in a chain of channel sink providers, and all channel messages flow through this chain of sinks before the messages are serialized and transported.

Return to top


Property: ChannelData (read-only)
Summary
Gets the channel-specific data.
C# Syntax:
public object ChannelData {get;}
Implements:
IChannelReceiver.ChannelData
Remarks
The current property is used when RemotingServices.Marshal is called and an ObjRef is created.

Return to top


Property: ChannelName (read-only)
Summary
Gets the name of the current channel.
C# Syntax:
public string ChannelName {get;}
Implements:
IChannel.ChannelName
Remarks
This property is used to retrieve a specific channel when calling ChannelServices.GetChannel. If this property is not set, the system defaults to "http". If you want to register more than one HttpChannel, each must have a unique name. Set this property to the String.Empty string ("") if you want to ignore names, but avoid naming collisions. The system will allow any number of channels with the String.Empty.

Return to top


Property: ChannelPriority (read-only)
Summary
Returns the priority of the current channel.
C# Syntax:
public int ChannelPriority {get;}
Implements:
IChannel.ChannelPriority
Remarks
Higher numbers indicate a higher chance of being chosen to connect first. The default priority is 1, and negative numbers are allowed.

Return to top


Property: ChannelScheme (read-only)
Summary
Gets the type of listener to hook into (for example "http").
C# Syntax:
public string ChannelScheme {get;}
Implements:
IChannelReceiverHook.ChannelScheme
Remarks
The value of the current property is not case-sensitive.

Return to top


Property: ChannelSinkChain (read-only)
Summary
Gets the channel sink chain that the current channel is using.
C# Syntax:
public IServerChannelSink ChannelSinkChain {get;}
Implements:
IChannelReceiverHook.ChannelSinkChain
Remarks
Channel sinks provide a plug-in point that allows access to the underlying messages flowing through the channel as well as the stream used by the transport mechanism to send messages to a remote object. Channel sinks are linked together in a chain of ChannelSinkProviders and all channel messages flow through this chain of sinks before the message is finally serialized and transported.

Return to top


Property: Count (read-only)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Count

Summary
Gets the number of properties associated with the current channel object.
C# Syntax:
public virtual int Count {get;}
Implements:
ICollection.Count

Return to top


Property: IsFixedSize (read-only)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.IsFixedSize

Summary
Gets a Boolean value indicating whether the number of properties that can be entered into the current channel object is fixed.
C# Syntax:
public virtual bool IsFixedSize {get;}
Implements:
IDictionary.IsFixedSize
Remarks
In the current implementation BaseChannelObjectWithProperties.IsFixedSize returns true.

Return to top


Property: IsReadOnly (read-only)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.IsReadOnly

Summary
Gets a Boolean value indicating whether the collection of properties in the current channel object is read-only.
C# Syntax:
public virtual bool IsReadOnly {get;}
Implements:
IDictionary.IsReadOnly
Remarks
In the current implementation BaseChannelObjectWithProperties.IsReadOnly returns false.

Return to top


Property: IsSynchronized (read-only)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.IsSynchronized

Summary
Gets a value indicating whether the current dictionary of channel object properties is synchronized.
C# Syntax:
public virtual bool IsSynchronized {get;}
Implements:
ICollection.IsSynchronized
Remarks
The current implementation of BaseChannelObjectWithProperties.IsSynchronized returns false.

Return to top


Overridden Property: Item (read-write)
Summary
Gets or sets a channel property associated with the specified key.
C# Syntax:
public override object this[object key] {get; set;}
Parameters:

key

The key with which the requested property is associated.

Implements:
IDictionary.Item
Remarks


Note Channel properties are used to configure the channel at run time. For a list of possible channel properties and an example, see the conceptual topic at MSDN: channelformatterconfigurationproperties.
Example
			System.Runtime.Remoting.Channels.Http.HttpChannel channel =
				new System.Runtime.Remoting.Channels.Http.HttpChannel(8085);

			string proxyName = channel["proxyname"].ToString();
			string proxyPort = channel["proxyport"].ToString();

			System.Console.WriteLine("proxyname = {0}", proxyName);
			System.Console.WriteLine("proxyport = {0}", proxyPort);

    
See also:
MSDN: channelformatterconfigurationproperties

Return to top


Overridden Property: Keys (read-only)
Summary
Gets an ICollection of keys with which the channel properties are associated.
C# Syntax:
public override ICollection Keys {get;}
Implements:
IDictionary.Keys
Remarks
The current property returns the keys of channel properties of both HttpServerChannel and HttpClientChannel. For a list of possible channel properties and an example, see the conceptual topic at MSDN: channelformatterconfigurationproperties.
See also:
MSDN: channelformatterconfigurationproperties

Return to top


Overridden Property: Properties (read-only)
Summary
Gets an IDictionary of the channel properties associated with the current channel.
C# Syntax:
public override IDictionary Properties {get;}
Remarks
Channels properties are used to configure the channel at run time. The HttpChannel.Properties property returns channel properties of the underlying HttpServerChannel and HttpClientChannel. For a list of possible channel properties and an example, see the conceptual topic at MSDN: channelformatterconfigurationproperties.
See also:
MSDN: channelformatterconfigurationproperties

Return to top


Property: SyncRoot (read-only)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.SyncRoot

Summary
Gets an object that is used to synchronize access to the BaseChannelObjectWithProperties.
C# Syntax:
public virtual object SyncRoot {get;}
Implements:
ICollection.SyncRoot
Remarks
The current implementation of BaseChannelObjectWithProperties.SyncRoot returns a reference to the current instance of BaseChannelObjectWithProperties.

Return to top


Property: Values (read-only)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Values

Summary
Gets an ICollection of the values of the properties associated with the current channel object.
C# Syntax:
public virtual ICollection Values {get;}
Implements:
IDictionary.Values

Return to top


Property: WantsToListen (read-write)
Summary
Gets a Boolean value indicating whether the current instance wants to be hooked into the outside listener service.
C# Syntax:
public bool WantsToListen {get; set;}
Implements:
IChannelReceiverHook.WantsToListen
Example
			System.Runtime.Remoting.Channels.Http.HttpChannel channelWithPort =
				new System.Runtime.Remoting.Channels.Http.HttpChannel(8085);

			System.Runtime.Remoting.Channels.Http.HttpChannel channelNoPort =
				new System.Runtime.Remoting.Channels.Http.HttpChannel();

			// channelWithPort.WantsToListen is false. It is already listening.
			if (channelWithPort.WantsToListen) {
				System.Console.WriteLine("channelWithPort wants to listen.");
			}
			else {
				System.Console.WriteLine(
								"channelWithPort doesn't want to listen.");
			}
			
			// channelNoPort.WantsToListen is true.
			if (channelNoPort.WantsToListen) {
				System.Console.WriteLine("channelNoPort wants to listen.");
			}
			else {
				System.Console.WriteLine(
								"channelNoPort doesn't want to listen.");
			}

    

Return to top


Method: Add(
   object key,
   object value
)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Add

Summary
The current method must not be implemented because it does not apply to the way IDictionary is being used in this case, and because BaseChannelObjectWithProperties.IsFixedSize returns true.
C# Syntax:
public virtual void Add(
   object key,
   object value
);
Parameters:

key

Indicates the key associated with the object contained in the value parameter.

value

Indicates the value to add.

Exceptions
Exception Type Condition
NotSupportedException The method was called.
Implements:
IDictionary.Add

Return to top


Method: AddHookChannelUri(
   string channelUri
)
Summary
Adds a URI on which the channel hook should listen.
C# Syntax:
public void AddHookChannelUri(
   string channelUri
);
Parameters:

channelUri

The channel URI on which the channel hook is listening.

Implements:
IChannelReceiverHook.AddHookChannelUri
Remarks


Note Client code should not call the HttpChannel.AddHookChannelUri method directly.
Example
The following example demonstrates the functionality of the HttpChannel.AddHookChannelUri method. Because client code should not call this method directly, the example demonstrates an implementation of the method in a class that mimics the behavior of the HttpChannel class.
   class CustomChannel : BaseChannelWithProperties, IChannelReceiverHook,
                         IChannelReceiver, IChannel, IChannelSender {

      public void AddHookChannelUri(string channelUri) {

         if (channelUri != null) {
            string [] uris = dataStore.ChannelUris;
				
            // This implementation only allows one URI to be hooked in.
            if (uris == null) {
               string [] newUris = new string[1];
               newUris[0] = channelUri;
               dataStore.ChannelUris = newUris;
               wantsToListen = false;
            } else {
               string msg = "This channel is already listening for " +
                  "data, and can't be hooked into at this stage.";
               throw new System.Runtime.Remoting.RemotingException(msg);
            }
         }
      }
      // The rest of CustomChannel's implementation.

    

Return to top


Method: Clear()
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Clear

Summary
The current method must not be implemented because it does not apply to the way IDictionary is being used in this case, and because BaseChannelObjectWithProperties.IsFixedSize returns true.
C# Syntax:
public virtual void Clear();
Exceptions
Exception Type Condition
NotSupportedException The method was called.
Implements:
IDictionary.Clear

Return to top


Method: Contains(
   object key
)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Contains

Summary
Returns a Boolean value indicating whether the current channel object contains a property associated with the specified key.
C# Syntax:
public virtual bool Contains(
   object key
);
Parameters:

key

The key the requested property is associated with.

Return Value:
A Boolean value indicating whether the current channel object contains a property associated with the specified key.
Implements:
IDictionary.Contains
Remarks

Return to top


Method: CopyTo(
   Array array,
   int index
)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.CopyTo

Summary
The current method is not supported by the BaseChannelObjectWithProperties.
C# Syntax:
public virtual void CopyTo(
   Array array,
   int index
);
Parameters:

array

The array to copy the properties to.

index

The index where to begin copying.

Exceptions
Exception Type Condition
NotSupportedException The method was called.
Implements:
ICollection.CopyTo

Return to top


Method: CreateMessageSink(
   string url,
   object remoteChannelData,
   out string objectURI
)
Summary
Returns a channel message sink that delivers messages to the specified URL or channel data object.
C# Syntax:
public IMessageSink CreateMessageSink(
   string url,
   object remoteChannelData,
   out string objectURI
);
Parameters:

url

The URL to which the new sink should deliver messages. Can be null.

remoteChannelData

The channel data object of the remote host to which the new sink should deliver messages. Can be null.

objectURI

When this method returns, contains a URI of the new channel message sink that delivers messages to the specified URL or channel data object. This parameter is passed uninitialized.

Return Value:
A channel message sink that delivers messages to the specified URL or channel data object.
Implements:
IChannelSender.CreateMessageSink
Remarks
The HttpChannel.CreateMessageSink method returns a channel message sink that delivers messages to either the specified URL or channel data object. If the uri parameter is null, remoteChannelData is used as a target for the sink. Either the url or remoteChannelData parameters can be null, but not both.

Channel sinks provide a plug-in point that allows access to the underlying messages flowing through the channel as well as the stream used by the transport mechanism to send messages to a remote object. Channel sinks are linked together in a chain of ChannelSinkProviders and all channel messages flow through this chain of sinks before the message is finally serialized and transported.

Example
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Messaging;

class Class1 {
   static void Main() {
      
      // Create a remotable object.
      HttpChannel channel = new HttpChannel(8085);
      ChannelServices.RegisterChannel(channel);

      WellKnownServiceTypeEntry WKSTE = 
            new WellKnownServiceTypeEntry(typeof(HelloService),
                                          "Service", 
                                          WellKnownObjectMode.Singleton);
      RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);

      RemotingConfiguration.ApplicationName = "HelloServer";

      // Create a message sink for TempConverter.
      string objURI;
      IMessageSink sink = 
         channel.CreateMessageSink("http://localhost:8085/HelloServer",
                                   channel,
                                   out objURI);

      // Do processing on messsage sink...
      
      Console.WriteLine("Press <enter> to exit");
      Console.ReadLine();
   }
}

    

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~HttpChannel();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetEnumerator()
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.GetEnumerator

Summary
Returns an IDictionaryEnumerator that enumerates over all the properties associated with the current channel object.
C# Syntax:
public virtual IDictionaryEnumerator GetEnumerator();
Return Value:
An IDictionaryEnumerator that enumerates over all the properties associated with the current channel object.
Implements:
IDictionary.GetEnumerator

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetUrlsForUri(
   string objectURI
)
Summary
Returns an array of all the URLs for an object with the specified URI, hosted on the current HttpChannel.
C# Syntax:
public string[] GetUrlsForUri(
   string objectURI
);
Parameters:

objectURI

The URI of the object for which URL's are required.

Return Value:
An array of the URLs for an object with the specified URI, hosted on the current HttpChannel.
Implements:
IChannelReceiver.GetUrlsForUri
Remarks
This method is used by ChannelServices.GetUrlsForObject.
Example
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Http;

class Class1 {
   public static void Main() {

      // Create a remotable object.
      HttpChannel httpChannel = new HttpChannel(8085);

      WellKnownServiceTypeEntry WKSTE = 
         new WellKnownServiceTypeEntry(typeof(HelloService),
                                       "Service", 
                                       WellKnownObjectMode.Singleton);
      RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);

      RemotingConfiguration.ApplicationName = "HelloServer";

      // Print out the urls for HelloServer.
      string[] urls = httpChannel.GetUrlsForUri("HelloServer");
      
      foreach (string url in urls)
         System.Console.WriteLine("{0}", url);
      
   }
}

    

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Parse(
   string url,
   out string objectURI
)
Summary
Extracts the channel URI and the remote well known object URI from the specified URL.
C# Syntax:
public string Parse(
   string url,
   out string objectURI
);
Parameters:

url

The URL from which to extract the URI of the remote well known object.

objectURI

When this method returns, contains a String that holds the URI of the remote well known object. This parameter is passed uninitialized.

Return Value:
The URI of the current channel.
Implements:
IChannel.Parse
Remarks
A URI of an object is a value that uniquely identifies a specific object instance.
See also:
Uri

Return to top


Method: Remove(
   object key
)
Inherited
See base class member description: System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties.Remove

Summary
The current method must not be implemented because it does not apply to the way IDictionary is being used in this case, and because BaseChannelObjectWithProperties.IsFixedSize returns true.
C# Syntax:
public virtual void Remove(
   object key
);
Parameters:

key

The key that the object being removed is associated with.

Exceptions
Exception Type Condition
NotSupportedException The method was called.
Implements:
IDictionary.Remove

Return to top


Method: StartListening(
   object data
)
Summary
Instructs the current channel to start listening for requests.
C# Syntax:
public void StartListening(
   object data
);
Parameters:

data

Should always be null for HttpChannel.

Implements:
IChannelReceiver.StartListening
Remarks
The data object can be used to pass a specific initialization state to the channel.

Return to top


Method: StopListening(
   object data
)
Summary
Instructs the current channel to stop listening for requests.
C# Syntax:
public void StopListening(
   object data
);
Parameters:

data

Should always be null for HttpChannel.

Implements:
IChannelReceiver.StopListening
Remarks
The data object can be used to pass a specific state to the channel.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.