HttpClientChannel.CreateMessageSink(String, Object, String) 方法

定义

返回将消息传送到指定 URL 或信道数据对象的信道消息接收器。Returns a channel message sink that delivers messages to the specified URL or channel data object.

public:
 virtual System::Runtime::Remoting::Messaging::IMessageSink ^ CreateMessageSink(System::String ^ url, System::Object ^ remoteChannelData, [Runtime::InteropServices::Out] System::String ^ % objectURI);
public virtual System.Runtime.Remoting.Messaging.IMessageSink CreateMessageSink (string url, object remoteChannelData, out string objectURI);
abstract member CreateMessageSink : string * obj * string -> System.Runtime.Remoting.Messaging.IMessageSink
override this.CreateMessageSink : string * obj * string -> System.Runtime.Remoting.Messaging.IMessageSink
Public Overridable Function CreateMessageSink (url As String, remoteChannelData As Object, ByRef objectURI As String) As IMessageSink

参数

url
String

新接收器将把消息传送到的 URL。The URL to which the new sink will deliver messages. 可以为 nullCan be null.

remoteChannelData
Object

新接收器将把消息传送到的远程主机的信道数据对象。The channel data object of the remote host to which the new sink will deliver messages. 可以为 nullCan be null.

objectURI
String

此方法返回时,包含新信道消息接收器的 URI,该信道消息接收器将消息传送到指定 URL 或信道数据对象。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.

返回

IMessageSink

将消息传递给指定 URL 或信道数据对象的信道消息接收器。A channel message sink that delivers messages to the specified URL or channel data object.

实现

示例

下面的代码示例说明如何使用 CreateMessageSink 属性。The following code example shows how to use the CreateMessageSink property. 此代码示例是为类提供的更大示例的一部分 HttpClientChannelThis code example is part of a larger example provided for the HttpClientChannel class.

// Create a message sink.
String^ objectUri;
System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = clientChannel->CreateMessageSink( L"http://localhost:9090/RemoteObject.rem", nullptr,  objectUri );
Console::WriteLine( L"The URI of the message sink is {0}.", objectUri );
if ( messageSink != nullptr )
{
   Console::WriteLine( L"The type of the message sink is {0}.", messageSink->GetType() );
}
// Create a message sink.
string objectUri;
System.Runtime.Remoting.Messaging.IMessageSink messageSink =
    clientChannel.CreateMessageSink(
    "http://localhost:9090/RemoteObject.rem",
    null, out objectUri);
Console.WriteLine(
    "The URI of the message sink is {0}.",
    objectUri);
if (messageSink != null)
{
    Console.WriteLine("The type of the message sink is {0}.",
        messageSink.GetType().ToString());
}

注解

CreateMessageSink方法返回将消息传递到指定 URL 或信道数据对象的信道消息接收器。The CreateMessageSink method returns a channel message sink that delivers messages to either the specified URL or the channel data object. 如果 uri 参数为 nullremoteChannelData 则将用作接收器的目标。If the uri parameter is null, remoteChannelData is used as a target for the sink. urlremoteChannelData 参数可以为 null ,但不能同时为两者。Either the url or remoteChannelData parameters can be null, but not both.

适用于