O'Reilly logo

Programming WCF Services, 2nd Edition by Juval Lowy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Context Bindings

With .NET 3.5, WCF gained three additional bindings dedicated to managing custom contexts. These bindings, found in the System.WorkflowServices.dll assembly, are the BasicHttpContextBinding, the NetTcpContextBinding, and the WSHttpContextBinding. The context bindings all derive from their respective regular bindings:

public class BasicHttpContextBinding : BasicHttpBinding
{
   /* Same constructors as BasicHttpBinding */
}

public class NetTcpContextBinding : NetTcpBinding
{
   /* Same constructors as NetTcpBinding */

   public ProtectionLevel ContextProtectionLevel
   {get;set;}
}
public class WSHttpContextBinding : WSHttpBinding
{
   /* Same constructors as WSHttpBinding */

   public ProtectionLevel ContextProtectionLevel
   {get;set;}
}

In the case of the NetTcpContextBinding and the WSHttpContextBinding, the ContextProtectionLevel indicates how to protect the context while in transfer, as discussed in Chapter 10.

The context bindings are used exactly the same way as their base bindings, yet they add support for a dedicated context management protocol. These bindings can be used with or without a context. The context protocol lets you pass as a custom context a collection of strings in the form of pairs of keys and values, stored implicitly in the message headers. There are several important differences between using a context binding and using the direct message headers for passing out-of-band parameters to a custom context:

  • With a context binding, you can only set the information to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required