ウェブサービスのメッセージを辿る

最近ウィンドウズコミュニケーションファウンデーションWCF)の機能を復習しています。メッセージを送信する前か受信する前にログとコンソールに記録出来ます。
A message is basically an XML document which can be accessed from memory only once. Basically, a message inspector can create a buffered copy of this message, and a trace method can serialize it using the toString method of Message.
The steps to create a message inspector on the server are:
1. Write the MessageTracer class. This should implement the IDispatchMessageInspector class. The AfterReceiveRequest and BeforeSendReply methods should be overridden to call code which serializes the Message.
2. Create a Behavior to be executed within the ServiceHost on an endpoint for a URL. This class will implement the IEndpointBehavior interface. The ApplyDispatchBehavior method will add the MessageTracer class to endpointDispatcher.DispatchRuntime.Inspectors collection
3. Create a behavior extension, which subclasses BehaviorExtensionElement. This seems to be similar to a factory class, as it is used to generate the Behavior class from the XML configuration file (if you add the behavior directly to the ServiceHost/Endpoint, this and step 4 might be omitted). It exposes the CreateBehavior method (override to return custom behavior from 3) and type property (return typeof behavior)
4. edit XML configuration file for the service (like service.exe.config) under . , , and elements all need to be modified. Basically, you associate the behavior with the binding, and the extension with the behavior.