title: spring ws clientinterceptor example
body: <p>I need to add a custom soap header to an out going soap message in a spring ws 2.0 client.</p>
  
  <p>I am using a client interceptor as follows.....</p>
  
  <pre><code>public class MyWebServiceClientInterceptor implements ClientInterceptor {
  
      private QName qname = new QName(WEB_SERVICE_NAMESPACE, SOAP_HEADER_PART);
      private String testText = "&lt;userName&gt;myUser&lt;/userName&gt;&lt;role&gt;everything&lt;/role&gt;";
  
      @Override
      public boolean handleRequest(MessageContext context) throws WebServiceClientException {
          SoapMessage soapMessage = (SoapMessage) context.getRequest();
          SoapHeader soapHeader = soapMessage.getSoapHeader();
          SoapHeaderElement newHeader = soapHeader.addHeaderElement(qname);
          newHeader.setActorOrRole(MY_SOAP_ACTOR);
          newHeader.setText(testText);
          return true;
      }
  }  
  </code></pre>
  
  <p>I have confirmed the interceptor is called, but the header doesn't seem to get added. Am I meant to be doing some sort of "commit" to apply the header to the message ????</p>