How does WCF support duplex communication?
Ask by ICSM Computer
Updated 28 May 2025
WCF supports duplex communication using a callback contract, enabling two-way communication between a service and its client. This is useful for scenarios like chat applications, real-time notifications, or event-based systems.
How Duplex Communication Works in WCF
Key Components
ServiceContractCallbackContractInstanceContextModePerSessionto maintain the callback referencebindingNetTcpBinding,WSDualHttpBinding)Example
1. Define Callback Contract
2. Define Service Contract with Callback
3. Implement the Service
4. Create Client with Callback Implementation
5. Connect Client
Required Bindings for Duplex
NetTcpBindingWSDualHttpBindingNetNamedPipeBindingBasicHttpBinding