title: WSS4J with Spring WS : (WSSecurityEngine: Invalid timestamp The security semantics of the message have expired)
body: <p>I developped a ws (soap) based on Wss4jSecurityInterceptor's Spring implementation.</p>
  
  <p>The configuration is as follow :</p>
  
  <pre>
  ...
  securementActions=Timestamp Signature Encrypt
  ...
  securementSignatureParts={Element}{...schemas.xmlsoap.org/soap/envelope/}Body;{Element}...www.w3.org/2005/08/addressing}To;{Element}{...www.w3.org/2005/08/addressing}Action;{Element}{...www.w3.org/2005/08/addressing}MessageID;{Element}{...www.w3.org/2005/08/addressing}RelatesTo;{Element}{...docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp
  
  </pre>
  
  <p>When i call the ws from a client when the clock is set 2 minutes (or more) latter than server's clock i get the message below :</p>
  
  <blockquote>
    <p>org.apache.ws.security.WSSecurityException: The message has expired
    (WSSecurityEngine: Invalid timestamp The security semantics of the
    message have expired)</p>
  </blockquote>
  
  <p>I use SoapUI to test the ws.
  On the response that i get the body block cannot be decrypted on client-side.</p>
  
  <p><strong>Response when clocks are synchronized</strong></p>
  
  <pre>
  
      &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xenc=&quot;http://www.w3.org/2001/04/xmlenc#&quot;&gt;
         &lt;SOAP-ENV:Header xmlns:wsa=&quot;http://www.w3.org/2005/08/addressing&quot;&gt;
         ...
         &lt;/SOAP-ENV:Header&gt;
         &lt;SOAP-ENV:Body wsu:Id=&quot;id-148&quot; xmlns:wsu=&quot;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&quot;&gt;
            &lt;SOAP-ENV:Fault&gt;
               &lt;faultcode&gt;SOAP-ENV:Server&lt;/faultcode&gt;
               &lt;faultstring xml:lang=&quot;en&quot;&gt;error label&lt;/faultstring&gt;
               &lt;detail&gt;
                  &lt;submissionFault xmlns=&quot;xxxxxx&quot;&gt;
                     &lt;error xmlns=&quot;xxxxxxx&quot;&gt;
                        &lt;errorCode&gt;error code here&lt;/errorCode&gt;
                        &lt;errorDescription&gt;error description here&lt;/errorDescription&gt;
                        &lt;errorDetail&gt;errro detail here&lt;/errorDetail&gt;
                     &lt;/error&gt;
                  &lt;/submissionFault&gt;
               &lt;/detail&gt;
            &lt;/SOAP-ENV:Fault&gt;
         &lt;/SOAP-ENV:Body&gt;
      &lt;/SOAP-ENV:Envelope&gt;
  
  </pre>
  
  <p><strong>Response when both clocks are not synchronized</strong></p>
  
  <pre>
  
      &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;...&quot; xmlns:xenc=&quot...#&quot;&gt;
         &lt;SOAP-ENV:Header xmlns:wsa=&quot;...&quot;&gt;
         ...
         &lt;/SOAP-ENV:Header&gt;
         &lt;SOAP-ENV:Body wsu:Id=&quot;id-157&quot; xmlns:wsu=&quot;...&quot;&gt;
            &lt;xenc:EncryptedData Id=&quot;EncDataId-162&quot; Type=&quot;...&quot;&gt;
               &lt;xenc:EncryptionMethod Algorithm=&quot;...#aes256-cbc&quot;/&gt;
               &lt;ds:KeyInfo xmlns:ds=&quot;...#&quot;&gt;
                  &lt;wsse:SecurityTokenReference xmlns:wsse=&quot;...&quot;&gt;
                     &lt;wsse:Reference URI=&quot;#EncKeyId-xxxxxxxxxxxxxhhhhhyyyy&quot;/&gt;
                  &lt;/wsse:SecurityTokenReference&gt;
               &lt;/ds:KeyInfo&gt;
               &lt;xenc:CipherData&gt;
                  &lt;xenc:CipherValue&gt;PMam8TSjmX9gHDE7+/fekt575W+qWFC2xcMAXzAlTPfxoQ3ctBG9bUPUAsnMNQm41G9ya0EZaQtV
      zRL59IFW0wrowbJXhUHXvW0YPkAbIUSnnmWreQpHwy5oKA5DQWJ+nZTnyMdXq8ukxDPCP5ALlvGD
      wv685Fs14YmWupzXVBGufcu4XSGFI
      ...
      XhUkjHrOlrBL4PHiZ9imt
      nWLswfcay6friGSfkN2Z0U5oJ3XW034sVCONFBdZVNwia51nNmGTGwsMXJFxXLXCxv/lVP1p3tMq
      StoR11Otn8d/gcc06q+jBJDu5KXTgI5V6fHyW17jvV924AorYA44BiZ6ym5u4dti8fvCSFfj8shg
      /4DhGS16ATWFFfZ+QzTxaGEik1+d/+AbMc031wrO60hm7dIMasOegqD0BKUkEgkBbk0totU4TI55
      C3BHPmv44QPGpoOSmkGAjYYzfbv9GE6HeaUBVXviJqaA1q0BiIIklINMmnry9KU53mi59swqBNKz
      pF6cNDjKFGDNeRW9JLGNJq8dsnqK8nn7zE/sE2PxFGwJ+3qk40TuE6mjhA==&lt;/xenc:CipherValue&gt;
               &lt;/xenc:CipherData&gt;
            &lt;/xenc:EncryptedData&gt;
         &lt;/SOAP-ENV:Body&gt;
      &lt;/SOAP-ENV:Envelope&gt;
  
  </pre>
  
  <p>Any idea?</p>
  
  <p>Thanks</p>