Enterprise Integration Zone is brought to you in partnership with:

My name is Bruno Terkaly and I am a Developer Evangelist in Northern California. Over the past few months I have been presenting a wide variety of demos and slides highlighting the wealth of new features in Visual Studio 2008. Bruno is a DZone MVB and is not an employee of DZone and has posted 51 posts at DZone. You can read more from them at their website. View Full User Profile

WCF Bindings: How to Implement Reliable Messaging

  • submit to reddit


This post is about understanding some lower level details about endpoints. As we discussed previously, an endpoint has it’s ABCs.

  • A is for Address
  • B is for Binding
  • C is for Contract

Ultimately, Windows Communication Foundation is a framework for building services that process XML messages. The whole point of WCF is for applications to communicate across networks.

Windows Communication Foundation (WCF) uses bindings to define how it communicates with other software. The client will need to incorporate the same bindings as in the service.

The terms to learn about with respect to Bindings are:

  • Transport
  • Encoding
  • Protocol details

Transport Protocol

Windows Communication Foundation allows you to transmit messages using different transport protocols.

  • Hypertext Transfer Protocol (HTTP)
  • Transmission Control Protocol (TCP)
  • Message Queuing (also known as MSMQ)
  • Named pipes

HTTP leverages the traditional request/response pattern. HTTP is stateless, so if there is any multi page transactions, the application (server and client) needs to maintain state. the main value of HTTP is interoperatbility with non-WCF clients.


TCP is connection based and provides end-to-end error detection and correction. TCP is a great choice because it provides reliable data delivery. It handles lost packets and duplicate packets. The TCP transport is optimized for scenarios where both ends are using WCF. It is the fastest of all the bindings. TCP provides duplex communication and so can be used to implement duplex contracts, even if the client is behind network address translation (NAT).

Note A duplex contract enables clients and servers to communicate with each other. The calls can be initiated independently of the other one. It is comprised of two one-way contracts.

Named Pipes

Named Pipes is ideal for two or more WCF applications on a single computer, and you want to prevent any communication from another machine. Named pipes are efficient because they tie into the Windows operating system kernel, leveraging a section of shared memory that processes can use for communication.


MSMQ is allows applications to communicate in a failsafe manner. A queue is a temporary storage location from which messages can be sent and received reliably. This enables communication across networks and between computers, running Windows, which may not always be connected.


Encoding types represents how the data is structured across the wire. There are 3 main formats:

  • Text
  • Binary
  • MTOM
Text – for interoperability

Text uses base64 encoding, which can make messages up to 30% bigger. If you are sending binary data, this can introduce a large amount of overhead.

Binary – for speed

This is the fastest encoding. Unless you are sending very large messages, the binary format is ideal (with the assumption that text isn’t needed for interoperability)

MTOM – for large objects

MTOM is the W3C Message Transmission Optimization Mechanism, a method of efficiently sending binary data to and from Web services. MTOM doesn't use base64 encoding for binary attachments keeping the overall size small. MTOM is based on open specifications & hence is largely interoperable.

Message Protocol Details

WCF leverages SOAP for its network messaging protocol. SOAP, aka Simple Object Access Protocol, specifies how structured information is exchanged in the implementation of Web Services in computer networks. It relies on XML for its message format.

One big advantage is that SOAP can tunnel easily over existing firewalls and proxies, without modification. The disadvantage of SOAP is that it has a verbose XML format and can be slow.

One alternative to SOAP is JSON/XML.

With respect to SOAP, there are a number of WS-* specifications. These WS-* specifications can be broken into various categories:

Messaging Specifications WS-Addressing, WS-Enumeratio, WS-Eventing, WS-Transfer
Security Specifications WS-Security: SOAP Message Security, WS-Security: UsernameToken Profil, WS-Security: X.509 Certificate Token Profile, WS-SecureConversation, WS-SecurityPolicy, WS-Trust, WS-Federation, WS-Federation Active Requestor Profil, WS-Federation Passive Requestor Profil, WS-Security: Kerberos Binding
Reliable Messaging Specifications WS-ReliableMessaging
Transaction Specifications WS-Coordination, WS-AtomicTransaction, WS-BusinessActivity
Metadata Specifications WS-Policy, WS-PolicyAssertions, WS-PolicyAttachment, WS-Discover, WS-MetadataExchang, WS-MTOMPolicy
Management Specifications WS-Managemen, WS-Management Catalog, WS-ResourceTransfe,
Specification Profiles WS-I Basic Profile


In this hands-on lab, you will learn how to:

  • Create a Virtual Machine with Visual Studio 2013 RC from the Windows Azure Management Portal
  • Download and install SQL Server 2012 Express


The following is required to complete this hands-on lab:


In order to execute the exercises in this hands-on lab, you need to set up your environment.

  1. Start Visual Studio and open the previous project here: (http://blogs.msdn.com/b/brunoterkaly/archive/2013/10/18/getting-started-with-wcf-windows-communication-foundation-running-and-debugging-quickly.aspx)

Published at DZone with permission of Bruno Terkaly, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)