I'm currently spending some time getting acquainted with the WCF Channel model as I'm starting to write an experimental transport channel for something I'm playing with. It's been quite an interesting experience, and I thought I might share what I learn as I go along in a series of small articles here.
I'm not going to post a step by step explanation of how to build a transport channel (others have already done so, see below), but rather focus more on specific things I find interesting and clear up things I find confusing as I go along.
Resources
One of the first things I did was look around the net for resources on the WCF Channel model and samples. A lot of the documentation around blogs on this topic is fairly old and talks about early implementations of the channel model which are not correct anymore, though I still found some good stuff even there.
Here are some of the articles and documentation which I've found more useful so far:
- Yasser Shohoud also has a few articles on Channel Related topics: Meet the WCF Channel Model - Part 1 and Part 2
- Nicholas Allen has a host of good Channel-related stuff. Here are some of the best ones:
- Design Pattern for Building Channel Factories and Listeners
- Asymmetry Between Listeners and Factories
- Mapping Channels to Shapes
- Windows Communication Foundation Channel Shapes and then read the followups on IInputChannel, IOutputChannel, IRequestChannel, IReplyChannel and IRequestContext.
- Kenny Wolf has a series of articles on Channel-related topics. However, be aware that a lot of it is fairly old stuff and its a bit outdated (some of it shows an old version of the UDP Transport sample). Some interesting tidbits, though.
- The WCF Channels Mini Book from the WCF Team, which I ran into through Jeff Barnes blog. A lot of this stuff is covered elsewhere, but I did find chapter 4 to be far more interesting as it covers sessionful channels (which are not talked about a lot on other places).
- Clemens Vasters on MSDN TV talking about bindings and channels.
Here are some of the samples that I've found:
- The UdpTransport sample: This one is good in that it's a fairly simple protocol and channel, and thus is a bit easier to follow. Also, it's an example of dealing with one-way protocols, while a few other samples are more focused on two-way protocols.
- The Amazon SQS Transport Sample: Another simple one-way transport channel. If you've seen the UDP sample, you've seen this one, as they are pretty similar (in fact, most of the XML doc comments on the SQS sample still refer to the original UDP sample code!).
- WSE 3.0 TCP Interop Channel Sample: This one is a pretty interesting example of building a two-way, session aware transport channel for WCF, which in this case interoperates with the WSE 3.0 TCP channel.
- Nicholas Allen's Custom File Transport Channel Sample, broken in 11 parts: 1 - Planning, 2 - Server, 3 - Client, 4 - Binding and Binding Element, 5 - Channel Basics, 6 - Channel Factory, 7 - Request Channel, 8 - Channel Listener, 9 - Reply Channel, 10 - Request Context, 11 - Putting it Together. By far, Nicholas' sample has been my favorite one, as it is better explained and has much simpler code (thus it is easier to follow).
- Steve Maine had a Soap.SMTP sample transport for WCF Beta 2. Haven't had the time to look in detail on this one and check if it's too outdated, though it does look interesting.