Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IRequestChannel Interface

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Defines the contract that a channel must implement to be on the requesting side of a request-reply communication between messaging endpoints.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public interface IRequestChannel : IChannel, 
	ICommunicationObject

The IRequestChannel type exposes the following members.

  NameDescription
Public propertyRemoteAddressGets the remote address to which the request channel sends messages.
Public propertyStateGets the current state of the communication-oriented object. (Inherited from ICommunicationObject.)
Public propertyViaGets the transport address to which the request is send.
Top

  NameDescription
Public methodAbortCauses a communication object to transition immediately from its current state into the closed state. (Inherited from ICommunicationObject.)
Public methodBeginClose(AsyncCallback, Object)Begins an asynchronous operation to close a communication object. (Inherited from ICommunicationObject.)
Public methodBeginClose(TimeSpan, AsyncCallback, Object)Begins an asynchronous operation to close a communication object with a specified time-out. (Inherited from ICommunicationObject.)
Public methodBeginOpen(AsyncCallback, Object)Begins an asynchronous operation to open a communication object. (Inherited from ICommunicationObject.)
Public methodBeginOpen(TimeSpan, AsyncCallback, Object)Begins an asynchronous operation to open a communication object within a specified interval of time. (Inherited from ICommunicationObject.)
Public methodBeginRequest(Message, AsyncCallback, Object)Begins an asynchronous operation to transmit a request message to the reply-side of a request-reply message exchange.
Public methodBeginRequest(Message, TimeSpan, AsyncCallback, Object)Begins an asynchronous operation to transmit a request message to the reply-side of a request-reply message exchange within a specified interval of time.
Public methodClose()Causes a communication object to transition from its current state into the closed state. (Inherited from ICommunicationObject.)
Public methodClose(TimeSpan)Causes a communication object to transition from its current state into the closed state. (Inherited from ICommunicationObject.)
Public methodEndCloseCompletes an asynchronous operation to close a communication object. (Inherited from ICommunicationObject.)
Public methodEndOpenCompletes an asynchronous operation to open a communication object. (Inherited from ICommunicationObject.)
Public methodEndRequestCompletes an asynchronous operation to return a message-based response to a transmitted request.
Public methodGetProperty<T>Returns a typed object requested, if present, from the appropriate layer in the channel stack. (Inherited from IChannel.)
Public methodOpen()Causes a communication object to transition from the created state into the opened state. (Inherited from ICommunicationObject.)
Public methodOpen(TimeSpan)Causes a communication object to transition from the created state into the opened state within a specified interval of time. (Inherited from ICommunicationObject.)
Public methodRequest(Message)Sends a message-based request and returns the correlated message-based response.
Public methodRequest(Message, TimeSpan)Sends a message-based request and returns the correlated message-based response within a specified interval of time.
Top

  NameDescription
Public eventClosedOccurs when the communication object completes its transition from the closing state into the closed state. (Inherited from ICommunicationObject.)
Public eventClosingOccurs when the communication object first enters the closing state. (Inherited from ICommunicationObject.)
Public eventFaultedOccurs when the communication object first enters the faulted state. (Inherited from ICommunicationObject.)
Public eventOpenedOccurs when the communication object completes its transition from the opening state into the opened state. (Inherited from ICommunicationObject.)
Public eventOpeningOccurs when the communication object first enters the opening state. (Inherited from ICommunicationObject.)
Top

The IRequestChannel defines synchronous and asynchronous variants of an Request(Message) method that returns a response message. It also provides a RemoteAddress and Via properties to retrieve the endpoint address and URI to which the request message is sent.


// Initialize request channel factory with a binding and a remote endpoint address.
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
ChannelFactory<IRequestChannel> factory =
    new ChannelFactory<IRequestChannel>(binding, address);

// Create an IRequestChannel object and open it.
IRequestChannel channel = factory.CreateChannel();
channel.Open();

// Get the endpoint address for the channel.
EndpointAddress epa = channel.RemoteAddress;

// Get the transport address for the channel.
Uri via = channel.Via;

// Send a request message on  the channel.
Message request = Message.CreateMessage(MessageVersion.Soap11, "hello");

// Request  sent and correlated with a reply message.
Message reply = channel.Request(request);

reply.Close();
channel.Close();
factory.Close();


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show: