100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
.NET Framework

WCF Message Exchange Patterns

Explains the three message exchange patterns (MEPs) — One-Way, Request-Reply, and Duplex — that define how messages flow between a WCF client and service.

Communication PatternsIntermediate8 min readJul 10, 2026
Analogies

Understanding Message Exchange Patterns

A Message Exchange Pattern (MEP) defines the shape of communication for a WCF operation: whether the client waits for a reply, sends and forgets, or opens a channel the service can call back through. WCF supports three MEPs — One-Way, Request-Reply, and Duplex — and the pattern for an operation is determined by the OperationContract attribute (IsOneWay), the presence of a return value or out/ref parameters, and whether the chosen binding supports duplex callbacks at all.

🏏

Cricket analogy: Choosing a MEP is like choosing how a captain communicates a field change: a shouted instruction to the fielder is one-way, a review referral to the third umpire that returns a decision is request-reply, and the walkie-talkie link between captain and coach during a strategic timeout that can interrupt either way is duplex.

Request-Reply: The Default Pattern

Request-Reply is the default MEP for any operation whose contract has a return type or out/ref parameters. The client sends a request message and blocks (or awaits, in async proxies) until the service returns a response message correlated back to the original by matching the reply's RelatesTo header to the request's MessageId. This pattern works with the most common bindings — BasicHttpBinding, WSHttpBinding, and NetTcpBinding — and gives the client a natural way to detect failures, since a SOAP fault can be returned as the reply.

🏏

Cricket analogy: Correlating a reply to its request is like a DRS review: the on-field umpire sends a specific query to the third umpire, and the response that comes back is matched to that exact delivery, not some earlier ball in the over.

One-Way Operations

Marking an operation with [OperationContract(IsOneWay = true)] tells WCF the client should not wait for any response: the method must return void, cannot declare out or ref parameters, and any exception thrown on the service side cannot be relayed back synchronously because there is no reply channel. The client's proxy call typically returns as soon as the message is handed to the transport, which means dispatch is not the same as guaranteed delivery — for durable, guaranteed one-way messaging you need a queued transport such as netMsmqBinding rather than relying on HTTP or TCP alone.

🏏

Cricket analogy: It's like a twelfth man running onto the field to deliver a drinks message to the batsman — the message is dropped off and the runner jogs back without waiting to see whether the batsman actually reads it.

Duplex and Choosing the Right Pattern

The Duplex MEP lets the service initiate calls back to the client over a callback channel, which requires a binding that supports it — WSDualHttpBinding or NetTcpBinding — plus a CallbackContract declared on the service contract. It is the right fit for scenarios like progress notifications, chat, or stock-ticker style push updates, where the server needs to reach the client without the client polling. Choosing among the three MEPs is ultimately a trade-off between simplicity (Request-Reply), throughput and fire-and-forget efficiency (One-Way), and interactive, event-driven communication (Duplex), each carrying different implications for session state, threading, and reliability.

🏏

Cricket analogy: Opting for a duplex-capable binding is like a team choosing to run a stump microphone feed both ways during a broadcast, versus just a simple post-match interview — it costs more setup but lets commentary and the players' reactions flow live in both directions.

csharp
[ServiceContract]
public interface IOrderService
{
    // Request-Reply (default): client blocks for a return value
    [OperationContract]
    OrderConfirmation PlaceOrder(OrderRequest request);

    // One-Way: fire-and-forget, must return void
    [OperationContract(IsOneWay = true)]
    void LogAuditEvent(AuditEvent evt);
}

[ServiceContract(CallbackContract = typeof(IOrderStatusCallback))]
public interface IOrderTrackingService
{
    [OperationContract]
    void SubscribeToOrder(int orderId);
}

public interface IOrderStatusCallback
{
    [OperationContract(IsOneWay = true)]
    void OnStatusChanged(int orderId, string newStatus);
}

Correlation for Request-Reply and Duplex relies on SOAP message headers: every request carries a unique MessageId, and the corresponding reply (or callback) carries a RelatesTo header pointing back to it. This is how a WCF client proxy matches an asynchronous-looking network exchange to the specific call that initiated it, even when multiple calls are in flight concurrently.

  • WCF defines three Message Exchange Patterns: One-Way, Request-Reply, and Duplex.
  • Request-Reply is the default whenever an operation has a return value or out/ref parameters.
  • One-Way operations must return void, cannot use out/ref parameters, and cannot synchronously propagate faults.
  • Dispatch of a one-way message is not the same as guaranteed delivery; use netMsmqBinding for durable queued delivery.
  • Duplex requires a CallbackContract and a binding that supports it, such as WSDualHttpBinding or NetTcpBinding.
  • Correlation between requests, replies, and callbacks is done via MessageId and RelatesTo SOAP headers.
  • Choosing the right MEP is a trade-off between simplicity, throughput, and interactivity.

Practice what you learned

Was this page helpful?

Topics covered

#NETFramework#WCFWindowsCommunicationFoundationStudyNotes#MicrosoftTechnologies#WCFMessageExchangePatterns#WCF#Message#Exchange#Patterns#StudyNotes#SkillVeris