title: SoapHeaderException: SOAP header Security was not understood using WSE3
body: <p>I'm using WSE3 in .Net to connect to a third party Java WebService. The SOAP request and response captured in Fiddler shows that the communication is working good.</p>
  
  <p>Response:</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;SOAP-ENV:Header&gt;
          &lt;wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
              &lt;wsu:Timestamp wsu:Id="XWSSGID-1508410623170-1719544205" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
                  &lt;wsu:Created&gt;2017-10-19T10:57:03.170Z&lt;/wsu:Created&gt;
                  &lt;wsu:Expires&gt;2017-10-19T11:02:03.170Z&lt;/wsu:Expires&gt;
              &lt;/wsu:Timestamp&gt;
              &lt;wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="XWSSGID-15084106231701759910641" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;XXX&lt;/wsse:BinarySecurityToken&gt;
              &lt;ds:Signature Id="XWSSGID-15084106231701266839262" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
                  &lt;ds:SignedInfo&gt;
                      &lt;ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"&gt;
                          &lt;InclusiveNamespaces PrefixList="wsse SOAP-ENV" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
                      &lt;/ds:CanonicalizationMethod&gt;
                      &lt;ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/&gt;
                      &lt;ds:Reference URI="#XWSSGID-15084106231711433609101"&gt;
                          &lt;ds:Transforms&gt;
                              &lt;ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"&gt;
                                  &lt;InclusiveNamespaces PrefixList="SOAP-ENV dss ds" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
                              &lt;/ds:Transform&gt;
                          &lt;/ds:Transforms&gt;
                          &lt;ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt;
                          &lt;ds:DigestValue&gt;bBWZxXap0n3oD/jodYRkD4J32Uk=&lt;/ds:DigestValue&gt;
                      &lt;/ds:Reference&gt;
                      &lt;ds:Reference URI="#XWSSGID-1508410623170-1719544205"&gt;
                          &lt;ds:Transforms&gt;
                              &lt;ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"&gt;
                                  &lt;InclusiveNamespaces PrefixList="wsu wsse SOAP-ENV" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
                              &lt;/ds:Transform&gt;
                          &lt;/ds:Transforms&gt;
                          &lt;ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt;
                          &lt;ds:DigestValue&gt;cwRM0nhUrQZ7J18qpE8pYsEryJU=&lt;/ds:DigestValue&gt;
                      &lt;/ds:Reference&gt;
                  &lt;/ds:SignedInfo&gt;
                  &lt;ds:SignatureValue&gt;xxx&lt;/ds:SignatureValue&gt;
                  &lt;ds:KeyInfo&gt;
                      &lt;wsse:SecurityTokenReference wsu:Id="XWSSGID-1508410623170704353769" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
                          &lt;wsse:Reference URI="#XWSSGID-15084106231701759910641" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/&gt;
                      &lt;/wsse:SecurityTokenReference&gt;
                  &lt;/ds:KeyInfo&gt;
              &lt;/ds:Signature&gt;
          &lt;/wsse:Security&gt;
      &lt;/SOAP-ENV:Header&gt;
      &lt;SOAP-ENV:Body wsu:Id="XWSSGID-15084106231711433609101" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
          &lt;dss:SignResponse Profile="urn:oasis:names:tc:dss:1.0:profiles:timestamping" RequestID="Id-eba85779-cb45-46ae-afac-01eb3e2bee3e" xmlns:dss="urn:oasis:names:tc:dss:1.0:core:schema"&gt;
              &lt;dss:Result&gt;
                  &lt;dss:ResultMajor&gt;urn:oasis:names:tc:dss:1.0:resultmajor:Success&lt;/dss:ResultMajor&gt;
              &lt;/dss:Result&gt;
              &lt;dss:SignatureObject&gt;
                  &lt;dss:Timestamp&gt;
                      &lt;ds:Signature Id="Id-cde5fcd8-1c04-4210-871a-1bb97cfa7a42" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
                          &lt;ds:SignedInfo Id="Id-f42a6e7f-b33d-4428-bc6a-40b059aed56f"&gt;
                              &lt;ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
                              &lt;ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/&gt;
                              &lt;ds:Reference Id="Id-8e6406fd-1f65-4bf3-bf38-3d19be32f128"&gt;
                                  &lt;ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/&gt;
                                  &lt;ds:DigestValue&gt;nGnDhLgyV9QPz/Q6Ojkmo6W7oWqAxQS1oZR+sqA7z8g=&lt;/ds:DigestValue&gt;
                              &lt;/ds:Reference&gt;
                              &lt;ds:Reference Id="Id-4a2243c5-f9b0-45a3-b80a-eac691800ec1" Type="urn:oasis:names:tc:dss:1.0:core:schema:XMLTimeStampToken" URI="#TSTInfo-Id-20bbc349-cd32-48c2-82c2-67f136af87e6"&gt;
                                  &lt;ds:Transforms&gt;
                                      &lt;ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
                                  &lt;/ds:Transforms&gt;
                                  &lt;ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/&gt;
                                  &lt;ds:DigestValue&gt;ziq2t3aNBb5Myk0DM41uW7tfkxP7BCNIvXMLGCX1f9o=&lt;/ds:DigestValue&gt;
                              &lt;/ds:Reference&gt;
                          &lt;/ds:SignedInfo&gt;
                          &lt;ds:SignatureValue&gt;xxx&lt;/ds:SignatureValue&gt;
                          &lt;ds:KeyInfo&gt;
                              &lt;ds:X509Data&gt;
                                  &lt;ds:X509Certificate&gt;xxx&lt;/ds:X509Certificate&gt;
                              &lt;/ds:X509Data&gt;
                          &lt;/ds:KeyInfo&gt;
                          &lt;ds:Object Id="TSTInfo-Id-20bbc349-cd32-48c2-82c2-67f136af87e6" MimeType="application/xml"&gt;
                              &lt;dss:TstInfo&gt;
                                  &lt;dss:SerialNumber&gt;150840777629299685&lt;/dss:SerialNumber&gt;
                                  &lt;dss:CreationTime&gt;2017-10-19T12:57:03.102+02:00&lt;/dss:CreationTime&gt;
                                  &lt;dss:Policy&gt;urn:oid:1.3.4.6.1.3.4.6&lt;/dss:Policy&gt;
                                  &lt;dss:ErrorBound&gt;PT1.001002S&lt;/dss:ErrorBound&gt;
                                  &lt;dss:Ordered&gt;true&lt;/dss:Ordered&gt;
                                  &lt;dss:TSA Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName"&gt;CN=Politica2,O=MDEF,OU=PKI,ST=Madrid,C=ES&lt;/dss:TSA&gt;
                              &lt;/dss:TstInfo&gt;
                          &lt;/ds:Object&gt;
                      &lt;/ds:Signature&gt;
                  &lt;/dss:Timestamp&gt;
              &lt;/dss:SignatureObject&gt;
          &lt;/dss:SignResponse&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>But Microsoft.Web.Services3 is throwing this exception:</p>
  
  <pre><code>System.Web.Services.Protocols.SoapHeaderException: SOAP header Security was not understood.
     at System.Web.Services.Protocols.SoapHeaderHandling.SetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client)
     at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
     at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
  </code></pre>
  
  <p>I tried some solutions like this: <a href="https://geeknotes.wordpress.com/2007/03/15/wse-30-hell-soap-header-security-was-not-understood/" rel="nofollow noreferrer">https://geeknotes.wordpress.com/2007/03/15/wse-30-hell-soap-header-security-was-not-understood/</a></p>
  
  <p>But it doesn't work. Any ideas?</p>