title: WCF IClientMessageInspector Logging Discrepancy Regarding Action
body: <p>I am logging outgoing WCF Soap requests from my application, and discovered a discrepancy between what I'm logging and what actually goes out to the server via the wire.</p>
  
  <p>Here is what I'm logging:</p>
  
  <pre><code> &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
   &lt;s:Header&gt;
      &lt;Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://tempuri.org/myinterface&lt;/Action&gt;
   &lt;/s:Header&gt;
   &lt;s:Body&gt;
      &lt;myinterface xmlns="http://tempuri.org/"&gt;
      ...
  </code></pre>
  
  <p>Here is what actually goes out (captured with WireShark):</p>
  
  <pre><code> &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
   &lt;s:Body&gt;
     &lt;myinterface xmlns="http://tempuri.org/"&gt;
     ...
  </code></pre>
  
  <p>You'll notice that the WireShark capture does not have the Header or Action elements.</p>
  
  <p>I only noticed this because I tried pushing my logged request out through SoapUI.</p>
  
  <p>I'm using this code to log the request:</p>
  
  <pre><code>public class InspectorBehavior : IEndpointBehavior
  {
      public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
      {
          clientRuntime.MessageInspectors.Add(new WCFMessageInspector());
      }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>public class WCFMessageInspector : IClientMessageInspector
  { 
      public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
      {
          Log(request.ToString());
  
          return null;
      }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>    client.Endpoint.Address = new System.ServiceModel.EndpointAddress(address);
      client.Endpoint.Behaviors.Add(new InspectorBehavior());
  </code></pre>
  
  <p>Does anyone know if there's a way to capture exactly what is going out (verbatim), without any post-processing as shown above?</p>