The WCF MessageEncoder Decoded 1
The MessageEncoder
MessageEncoders typically inhabit Transport Channels, although MessageEncoders can be used elsewhere in the Channel Stack. Often, a MessageEncoder’s sole purpose is to turn the bytes coming over the wire into a WCF Message Class representation.
Typically, bytes on the wire are a Multipurpose Internet Mail Extensions (MIME) content type. MIME support is a WCF cornerstone. WCF is also built for SOAP-based interactions. In fact, WCF comes equipped to handle multiple SOAP versions and various forms of XML data. MessageEncoders shipping with WCF can build messages from various content and SOAP protocols.
So, with all this support for content and protocols, why would you build your own MessageEncoder?
Why Build Your Own?
As you may have guessed, not all data coming over the wire can be neatly categorized and packaged. Therefore, creating a Message class representation may require some custom handling. Custom handling may entail data decrypting/encrypting or may be supplemented by an additional source.
Other reasons for building your own MessageEncoder is tht you may want to utilize a custom Message class throughout your Channel Stack or you may want to apply a transformation to the incoming data as you create a Message class.
Whatever the case when writing your own MessageEncoder, you will probably apply the same general formula and toolset. Now, you’re going to explore the sample code and I’m going to share the formula and toolset for building your own MessageEncoder.
Tags: decode, encode, messagedecoder, MessageEncoder, wcf, xml

May 14th, 2008 at 11:19 pm
[…] the MessageEncode is embedded inside of a WCF. As stated earlier, normally a MessageEncoder inhabits a Transport […]
May 19th, 2008 at 12:37 am
[…] is the base class for all MessageEncoders. MessageEncoder contains overridable versions of the overloaded ReadMessage and WriteMessage […]