title: How to log full raw WCF client request from client side?
body: <p>I have a WCF client with TransportWithMessageCredential security mode. When try to log request using BeforeSendRequest</p>
  
  <pre><code>    public object BeforeSendRequest(ref Message request, IClientChannel channel)
      { 
          System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\tmp\\request_log.xml");
          file.WriteLine(request.ToString());
          file.Close();
  
          return null;
      }
  </code></pre>
  
  <p>have result without security tags</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;https://(skiped)&lt;/Action&gt;
      &lt;/s:Header&gt;
      &lt;s:Body&gt;
      ...
      &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>How can I log full raw request in client? It must be like this</p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
  &lt;s:Header&gt;
  &lt;o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
  &lt;u:Timestamp u:Id="_0"&gt;
  &lt;u:Created&gt;...&lt;/u:Created&gt;
  &lt;u:Expires&gt;..&lt;/u:Expires&gt;
  &lt;/u:Timestamp&gt;
  &lt;o:BinarySecurityToken&gt;
  &lt;!-- Removed--&gt;
  &lt;/o:BinarySecurityToken&gt;
  &lt;Signature xmlns="http://www.w3.org/2000/09/xmldsig#"&gt;
  &lt;SignedInfo&gt;
  ...
  &lt;/SignedInfo&gt;
  &lt;SignatureValue&gt;...&lt;/SignatureValue&gt;
  &lt;KeyInfo&gt;
  &lt;o:SecurityTokenReference&gt;
  ...
  &lt;/o:SecurityTokenReference&gt;
  &lt;/KeyInfo&gt;
  &lt;/Signature&gt;
  &lt;/o:Security&gt;
  &lt;Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;skiped&lt;/Action&gt;
  &lt;/s:Header&gt;
  &lt;s:Body&gt;
  ...
  &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>UPD. Security options for binding</p>
  
  <pre><code> &lt;security mode="TransportWithMessageCredential"&gt;
      &lt;transport clientCredentialType="None" proxyCredentialType="None"
        realm="" /&gt;
     &lt;message clientCredentialType="Certificate" algorithmSuite="Basic256" /&gt;
   &lt;/security&gt;
  </code></pre>