Building a custom MessageEncoder

MessageInspector can intercept the underlying messages of WCF service operation calls. However, this is not the only way for intercepting and customizing messages in a WCF service. In WCF extension architecture, there is another powerful component called MessageEncoder, which can also perform customization on the underlying messages of WCF service operation calls.

In this recipe, we will demonstrate how we can use a custom MessageEncoder to alter the raw message of a WCF service operation.

How to do it...

The sample service will use a custom MessageEncoder component to customize the SOAP XML content of each service operation call. The entire process will be as follows:

  • Create a custom MessageEncoder type
  • Create a ...

Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.