Resources for Custom Channel Authors from the WCF Core Communications Team
Note: The content and code posted here are all pre-release provided as is with no warranty. This content is based on the WCF Feb CTP. Please send feedback and requests in email to ces at microsoft.com

What is the WCF channel stack? The WCF channel stack is a layered communication stack with one or more channels that process messages. At the bottom of the stack is a transport channel that is responsible for adapting the channel stack to the underlying transport (e.g. TCP, HTTP, SMTP etc.). Above the transport channel there are 0 or more protocol channels (also known as layered channels) that implement a SOAP-based protocol.

Why write a custom WCF channel? Custom channels are a powerful and versatile extensibility point. You'd write a custom protocol channel if you want to implement a wire protocol. Examples of wire protocols include the WS-ReliableMessaging protocol (WCF already implements that one for you as a channel) and a chunking protocol (see the chunking channel sample below). You'd write a custom transport if you want to send/receive WCF messages over a transport other than the ones we ship in the box (we ship TCP, HTTP, Named Pipes, MSMQ, and PeerChannel). For example, you could write a UDP transport (there's a sample of that in the WCF SDK) or an SMTP transport. Another reason to write a WCF transport is to integrate with an existing system that's not exposed as a Web service. In this case your transport acts as an adapter adapting WCF messages to the existing system's message format or API allowing a WCF client to talk directly to the existing system. An example of that is the WSE 3.0 TCP transport sample below.

Code

  WSE 3.0 TCP Interop: This sample demonstrates how to write custom WCF transports. This particular example shows a duplex sessionful transport using TCP that interoperates with WSE 3.0. The sample shows a client calling a WSE 3.0 TCP sample. You can download WSE 3.0 here.

  Service activation over custom transport: Did you know that Windows Vista supports service activation over custom WCF transports? This sample shows you how to make service activation work over a custom transport. In this case the sample transport is UDP. This requires Windows Vista

  One-Way sessions over TCP/NP: This is an example of a layered channel showing how to transform a duplex session channel to one way session channels. Besides being a good example of how to write a shape-changing channel, it is useful for doing one-way sessions over TCP and Named Pipes.

  Chunking channel: Another example of a layered channel this one showing how to implement a message-based protocol that alters the messages as they are sent/received. This channel is useful for sending large amounts of data over channel stacks that require buffering e.g. when reliable messaging and/or message-based security are used.

  HTTP with binary binding: An example of writing a custom binding using existing transports and encoders. This sample consists of a binding that uses HTTP (or HTTPS) with the WCF binary encoder. This is especially useful in scenarios where you have WCF on both ends but your network or hosting infrastructure requires you to use HTTP rather than TCP. For example if you want to use IIS 6 for hosting and activation.

  Custom channel builder: This sample shows how to build a channel stack and dispatching messages from that stack in a custom way. It does this by implementing a custom service host that derives from ServiceHostBase. This sample requires IIS.

  Config code generator: Adding config support for your custom channel requires writing a lot of boiler plate code that can be tedious to write. This tool automatically generates that code for you from your custom binding element or binding. It's really fabulous!

  Basic channel tester: Once you've written all those custom channels you'll want a way to test them. This tool is a general framework for testing channels. It works by taking the binding you provide and creating a channel factory/channel listener and testing send/receive. A real handy way to test basic channel functionality without writing any test code.
Documentation, Talks, etc.

  WCF Channels mini book: A short book of eight chapters that explains the channel model and shows how to build custom channels. The chapters are:
  1. Introducing WCF Channels: An overview of WCF channels and how they're used.
  2. Channel State Machine: A drill down into the ICommunicationObject state machine and CommunicationObject.
  3. Channels Object Model: A survey of the interfaces and classes that make up the WCF channel model.
  4. Channel Shapes and Sessions: Explains the different channel shapes and the concept of sessions at the channel level.
  5. Exceptions, Faults and Tracing: Some guidance on what exception types to throw, how to treat faults, and how to trace from your custom channels.
  6. Layered Channel Walkthrough: A walkthrough of building a layered protocol channel. The example used is the chunking channel sample.
  7. Transport Channel Walkthrough: Coming soon. A walkthrough of building a transport channel. For now, check out Kenny's blog.
  8. Metadata Export and Import: Coming soon. How to export and import policy assersions for your custom channel. The UDP sample on Kenny's blog shows this.

  PDC 2005 custom channels talk: An overview of building custom protocol and transport channels.

  Kenny Wolf's blog: Kenny has lots of content on his blog about writing custom transports.

  Nicholas Allen's blog: Nicholas has been blogging regularly since he joined Microsoft. He has a blog category dedicated to channels.

  Yasser Shohoud's blog: Occasionally, there's a useful post here.