title: How to add Timetamp to SOAP header with SpringWS
body: <p>It seems the default option for adding a timestamp using SpringWS + Wss4j interceptor is to add the Timestamp within the security element within the header:</p>
  
  <pre><code>&lt;SOAP-ENV:Header&gt;
      &lt;wsse:Security&gt;
          ...
          &lt;wsu:Timestamp wsu:Id="TS-2"&gt;
              &lt;wsu:Created&gt;2013-09-19T17:43:31Z&lt;/wsu:Created&gt;
              &lt;wsu:Expires&gt;2013-09-19T17:48:31Z&lt;/wsu:Expires&gt;
          &lt;/wsu:Timestamp&gt;
      &lt;/wsse:Security&gt;
  &lt;/SOAP-ENV:Header&gt;
  </code></pre>
  
  <p>However I'd like the Timestam element to be outside of the Security element (see below). Is this possible?</p>
  
  <pre><code>&lt;SOAP-ENV:Header&gt;
      &lt;wsse:Security&gt;
          ...
      &lt;/wsse:Security&gt;
      &lt;wsu:Timestamp wsu:Id="TS-2"&gt;
          &lt;wsu:Created&gt;2013-09-19T17:43:31Z&lt;/wsu:Created&gt;
          &lt;wsu:Expires&gt;2013-09-19T17:48:31Z&lt;/wsu:Expires&gt;
      &lt;/wsu:Timestamp&gt;
  &lt;/SOAP-ENV:Header&gt;
  </code></pre>
  
  <p>Spring config as follows:</p>
  
  <pre><code>&lt;bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/&gt;
  
  &lt;bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"&gt;
      &lt;constructor-arg ref="messageFactory"/&gt;
      &lt;property name="defaultUri" value="https://domain.com/service"/&gt;
      &lt;property name="marshaller" ref="marshaller"/&gt;
      &lt;property name="unmarshaller" ref="marshaller"/&gt;
      &lt;property name="interceptors"&gt;
          &lt;list&gt;
              &lt;ref local="wsClientSecurityInterceptor"/&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="wsClientSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor"&gt;  
      &lt;!-- Validation Actions --&gt;
      &lt;property name="validationActions" value="NoSecurity" /&gt;
  
      &lt;!-- Securement Actions --&gt;
      &lt;property name="securementActions" value="UsernameToken Timestamp" /&gt; 
  
      &lt;!-- timestamp options --&gt;
      &lt;property name="timestampStrict" value="false"/&gt; 
      &lt;property name="timestampPrecisionInMilliseconds" value="false"/&gt; 
  
      &lt;!-- username --&gt;
      &lt;property name="securementUsername" value="TheUsername"/&gt;
      &lt;property name="securementPassword" value="ThePassword"/&gt;
      &lt;property name="securementMustUnderstand" value="true" /&gt;
  &lt;/bean&gt;
  </code></pre>