Export (0) Print
Expand All

HttpChannel Class

Provides an implementation for a sender-receiver channel that uses the HTTP protocol to transmit messages.

For a list of all members of this type, see HttpChannel Members.

System.Object
   System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties
      System.Runtime.Remoting.Channels.BaseChannelWithProperties
         System.Runtime.Remoting.Channels.Http.HttpChannel

[Visual Basic]
Public Class HttpChannel
   Inherits BaseChannelWithProperties
   Implements IChannelReceiver, IChannel, IChannelSender, _
   IChannelReceiverHook
[C#]
public class HttpChannel : BaseChannelWithProperties,
   IChannelReceiver, IChannel, IChannelSender, IChannelReceiverHook
[C++]
public __gc class HttpChannel : public BaseChannelWithProperties,
   IChannelReceiver, IChannel, IChannelSender, IChannelReceiverHook
[JScript]
public class HttpChannel extends BaseChannelWithProperties
   implements IChannelReceiver, IChannel, IChannelSender,
   IChannelReceiverHook

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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 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 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. To request that the remoting system choose an open port on your behalf, specify port "0" (zero). This will create an HttpServerChannel instance to listen for requests on the dyamically assigned port. This is typically done on the client to make sure that an HttpServerChannel is listening for callback methods.
supressChannelData true or false. Specifies that the channel will not contribute to the 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.

It is generally a good idea to use the DNS name of the computer, but when the IP Address for a particular NIC (usually a wireless NIC) is changing rapidly, you must configure the application to use the machineName to enable remoting to find the machine through DNS. However, where the computer name does not resolve with reasonable speed (if at all) and where the computer has more than one NIC, either physical or virtual (this is often the case with a dial-up connection or VPN network adapter), you should set the machineName property to the IP address of the NIC that is currently in use for that connection.

timeout A integer specifying the period after which the request will time out. To request an inifinite time-out period, specify -1.
allowAutoRedirect Gets or sets a value indicating whether the automatic handling of server redirects is enabled.
credentials Gets or sets an ICredential implementation that represents the identity of the client.
exclusiveAddressUse true or false. Specifies whether the server channel will prevent other applications from reusing the IP address/port combination by setting the SocketOptionName server socket option to SocketOptionName.ExclusiveAddressUse. The default is true.

This property is supported only by the .NET Framework version 1.1 on the following platforms: Windows NT 4.0 with SP4 or later, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family.

This property requires administrator privileges on platforms prior to the Windows Server 2003 family.

useAuthenticatedConnectionSharing A Boolean value directing the server channel to reuse authenticated connections rather than authenticate each incoming call. By default, this value is set to true if the useDefaultCredentials value is also set to true; otherwise, the value is set to false, which means that each call will be authenticated if the server requires authentication. This also applies to the programmatic equivalent, which is achieved either by creating an object that implements IDictionary, setting the "credentials" value to CredentialCache.DefaultCredentials, and passing that value to the channel sink, or by using the IDictionary returned from the ChannelServices.GetChannelSinkProperties method.

This name/value pair is supported only by version 1.1 of the .NET Framework on the following platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family.

unsafeAuthenticatedConnectionSharing A Boolean value indicating that the client will supply its own credentials and connection group name that the server should use to create an authenticated connection group. If this value is set to true, the connectionGroupName value must map to only one authenticated user. This name/value pair is ignored if the useAuthenticatedConnectionSharing value is set to true.

This name/value pair is supported only by version 1.1 of the .NET Framework on the following platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family.

connectionGroupName The name that will be used as the connection group name on the server if the unsafeAuthenticatedConnectionSharing value is also specified. This name/value pair is ignored if unsafeAuthenticatedConnectionSharing is not set to true. If specified, make sure that this name maps to only one authenticated user.

On Windows 98 and Windows Millennium Edition, there is no security ID to identify the authentication connection group name. On these platforms, therefore, there is one connection group name.If you want your application to pass an implementation of ICredentials or explicit username, password, and domain values in the HttpClientChannel properties, you can enable authentication connection sharing by also passing the unsafeAuthenticatedConnectionSharing name/value pair and the connectionGroupName name/value pair, making sure that the connectionGroupName value maps to only one authenticated user.

This name/value pair is supported only by version 1.1 of the .NET Framework on the following platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family.

Example

[Visual Basic, C#, C++] The following code example demonstrates a simple host application that registers an HttpChannel to listen for requests on port 9000.

[Visual Basic] 
Dim channelProperties As New ListDictionary()
channelProperties.Add("port", 9000)

Dim channel As New HttpChannel(channelProperties, New SoapClientFormatterSinkProvider(), New SoapServerFormatterSinkProvider())
ChannelServices.RegisterChannel(channel)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(SampleService), "MySampleService/SampleService.soap", WellKnownObjectMode.Singleton)

Console.WriteLine("** Press enter to end the server process. **")
Console.ReadLine()

[C#] 
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();

[C++] 
ListDictionary* channelProperties = new ListDictionary();

channelProperties->Add(S"port", __box(9000));

HttpChannel* channel = new HttpChannel(channelProperties,
    new SoapClientFormatterSinkProvider(),
    new SoapServerFormatterSinkProvider());

ChannelServices::RegisterChannel(channel);

RemotingConfiguration::RegisterWellKnownServiceType(__typeof(SampleService), 
    S"MySampleService/SampleService::soap",
    WellKnownObjectMode::Singleton);

Console::WriteLine(S"** Press enter to end the server process. **");
Console::ReadLine();

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Runtime.Remoting.Channels.Http

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Runtime.Remoting (in System.Runtime.Remoting.dll)

See Also

HttpChannel Members | System.Runtime.Remoting.Channels.Http Namespace | SoapFormatter | BinaryFormatter | Channel and Formatter Configuration Properties

Show:
© 2014 Microsoft