title: How to set a header element "mustunderstand=0" into a soap request with BasicHttpBinding and BasicHttpSecurityMode.TransportWithCredential:
body: <p>I'm using a .NET WCF Client with C# to consume a Java WebService. When I'm sending a request to this web service, the encapsulated WCF client always put the element <code>mustunderstand=1</code>, even with a customized MessageInspector that implements the <code>IClientMessageInspector</code> changing the header elements in the method <code>IClientMessageInspector.BeforeSendRequest</code>. I guess the BasicHttpBinding with a BasicHttpSecurityMode.TrasportWithCredentials, always put this element in the header of the request, ignoring these manualy added headers. </p>
  
  <p>This <code>mustunderstand=1</code> header element is triggering an error in the server side, and this server is out of our control. Id like to avoid this header element response errors changing the value of <code>mustunderstand=1</code> to <code>mustunderstand=0</code>.</p>
  
  <p>So there is a tip or technique to change the value of this <code>mustunderstand</code> header parameter? </p>
  
  <p>To ilustrate see the REQUEST RAW, RESPONSE RAW tracked by FIDDLER and MessageInspector.</p>
  
  <p>REQUEST RAW:</p>
  
  <pre><code>POST "WSDLADDRESS" HTTP/1.1
  MIME-Version: 1.0
  Content-Type: multipart/related; type="application/xop+xml";start="&lt;http://tempuri.org/0&gt;";boundary="uuid:a0f5ee5b-4543-4aa9-85be-f7af4e8ea289+id=1";start-info="text/xml"
  SOAPAction: "NAMEOFSOAPACTION"
  Host: wwwh.cnj.jus.br
  Content-Length: 5013
  Expect: 100-continue
  Accept-Encoding: gzip, deflate
  Connection: Keep-Alive
  
  
  --uuid:a0f5ee5b-4543-4aa9-85be-f7af4e8ea289+id=1
  Content-ID: &lt;http://tempuri.org/0&gt;
  Content-Transfer-Encoding: 8bit
  Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
  
  &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;2014-09-01T14:06:59.225Z&lt;/u:Created&gt;&lt;u:Expires&gt;2014-09-01T14:11:59.225Z&lt;/u:Expires&gt;&lt;/u:Timestamp&gt;&lt;o:BinarySecurityToken u:Id="uuid-562fb884-7bc7-4323-ac5e-29556b6c85aa-1" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"&gt;&lt;xop:Include href="cid:http://tempuri.org/1/635451664301180633" xmlns:xop="http://www.w3.org/2004/08/xop/include"/&gt;&lt;/o:BinarySecurityToken&gt;&lt;Signature xmlns="http://www.w3.org/2000/09/xmldsig#"&gt;&lt;SignedInfo&gt;&lt;CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;&lt;SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/&gt;&lt;Reference URI="#_0"&gt;&lt;Transforms&gt;&lt;Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;&lt;/Transforms&gt;&lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt;&lt;DigestValue&gt;cIusnusCxdoCXm4BhihEXGC3MMw=&lt;/DigestValue&gt;&lt;/Reference&gt;&lt;/SignedInfo&gt;&lt;SignatureValue&gt;LC4d/YhYHKRocSmORNWC0oQzCrLkG00b1iSZxDL/TflCQ3pJa7qYxPY07oUR4Ngull22V9fn1QBl1NOoRii8JjK1XjJYW8XQ+pVVMnf6l2guYJjYmTp7y2p+UT3JAQrlJIYj2sAu38obsthemAtec/miY3K5anq/AYTIr1slkyDJsm23w4boq3RfTD9mbU+U+KSF71vFi5RK8ryX/i9FEsayp0N0Hpw5SP/lOEI2IkOmw4Mpg2slCLIcQWJMuP+g6aZgLviVTQBgUE3ETwdVQIogmHChfeAtHCD9Knid4Bndyldq0WoTWzGJZ9PL8PXZJIMzQtYLP+XG/emAb3Bp1g==&lt;/SignatureValue&gt;&lt;KeyInfo&gt;&lt;o:SecurityTokenReference&gt;&lt;o:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" URI="#uuid-562fb884-7bc7-4323-ac5e-29556b6c85aa-1"/&gt;&lt;/o:SecurityTokenReference&gt;&lt;/KeyInfo&gt;&lt;/Signature&gt;&lt;/o:Security&gt;&lt;/s:Header&gt;&lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;consultarAvisosPendentes xmlns="http://www.cnj.jus.br/servico-intercomunicacao-2.2/"&gt;&lt;idRepresentado xmlns="http://www.cnj.jus.br/tipos-servico-intercomunicacao-2.2"/&gt;&lt;idConsultante xmlns="http://www.cnj.jus.br/tipos-servico-intercomunicacao-2.2"/&gt;&lt;senhaConsultante xmlns="http://www.cnj.jus.br/tipos-servico-intercomunicacao-2.2"/&gt;&lt;dataReferencia xmlns="http://www.cnj.jus.br/tipos-servico-intercomunicacao-2.2"&gt;01/09/2014&lt;/dataReferencia&gt;&lt;/consultarAvisosPendentes&gt;&lt;/s:Body&gt;&lt;/s:Envelope&gt;
  --uuid:a0f5ee5b-4543-4aa9-85be-f7af4e8ea289+id=1
  Content-ID: &lt;http://tempuri.org/1/635451664301180633&gt;
  Content-Transfer-Encoding: binary
  Content-Type: application/octet-stream
  
  0��0�ΠZN�(K��20�    ���j0
      *�H��
  
  �0o1
  0   UBR10U
  
  (...certificate data...)
  �����2o�w�|� ������#�d�e�Z9�KI��l����ɵ�v���Ka�����q�晚=]�ht���l�T�x�7&lt;IS�d@��T�d՘�30��T;l��3�ЉJ�K(���tP��oU�結$�"�4�4�x����p����\ނl�/0鈾yN�
  iu����y�-��Z�J���&lt;���P�5�i}��;&amp;u�t�DH�oc��@D�Mf}ue��I\Mk�鐈�^gF�_T'䌁U��ёN����qy;�P_����7F�dz��qLL
  �`g&gt;
  �C�﨨�%��a;���z�����n�$��O�Vz4��ѡ�D��V�3�X�!m��y���E��E��};��)�Jlv��+��6���RK
  �����w��k���@�XIB����?��qC��ġ��6n{n��s�̔-���
  |�����@+�Jv�r�%̓p�� *gy4��(�hA�⮫*m��bU��c�&gt;����}��h�����Y�(
  --uuid:a0f5ee5b-4543-4aa9-85be-f7af4e8ea289+id=1--
  </code></pre>
  
  <p>RESPONSE RAW:</p>
  
  <pre><code>HTTP/1.1 500 Internal Server Error
  Date: Mon, 01 Sep 2014 14:07:10 GMT
  X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
  Content-Type: text/xml;charset=UTF-8
  Vary: Accept-Encoding
  Connection: close
  Content-Length: 480
  
  &lt;env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'&gt;&lt;env:Header&gt;&lt;/env:Header&gt;&lt;env:Body&gt;&lt;env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'&gt;&lt;faultcode xmlns:codeNS='http://schemas.xmlsoap.org/soap/envelope/'&gt;codeNS:MustUnderstand&lt;/faultcode&gt;&lt;faultstring&gt;Unprocessed &amp;apos;mustUnderstand&amp;apos; header element: {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security&lt;/faultstring&gt;&lt;/env:Fault&gt;&lt;/env:Body&gt;&lt;/env:Envelope&gt;
  </code></pre>
  
  <p>MessageInspector:</p>
  
  <pre><code>    class MessageInspector : IClientMessageInspector
      {
          object IClientMessageInspector.BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel)
          {
              request.Headers.Add(MessageHeader.CreateHeader
                  (request.Headers[0].Name,
                  request.Headers[0].Namespace,
                  string.Empty,
                  false,
                  request.Headers[0].Actor,
                  request.Headers[0].Relay)
                  );
  
              request.Headers.RemoveAt(0);
  
              return Convert.DBNull;
          }
  
          public void AfterReceiveReply(ref Message reply, object correlationState)
          {
          }
      }
  </code></pre>
  
  <p>Request Headers Before:</p>
  
  <p><img src="https://i.stack.imgur.com/Av9XQ.png" alt="Request Headers Before"></p>
  
  <p>Request Headers After:</p>
  
  <p><img src="https://i.stack.imgur.com/Gazea.png" alt="Request Headers After"></p>