title: JAX-WS handleMessage within SOAPHandler is not getting called
body: <p>I'm trying to access the SOAP request and response via client side so that I can calculate the execution time for each call.  I've implemented a <code>SOAPHandler</code> to achieve this but the <code>handleMessage</code> method is not being invoked (breakpoint doesn't get hit or no log gets logged). I am using wsimport to create the client side classes/stubs and also passing a binding file in as a parameter to wsimport command.</p>
  
  <p>This is what I have done so far:</p>
  
  <p>My binding file - handler-chain.xml</p>
  
  <pre><code>&lt;jaxws:bindings
      xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:jxb="http://java.sun.com/xml/ns/jaxb"&gt;
      &lt;handler-chains xmlns="http://java.sun.com/xml/ns/javaee"&gt;
          &lt;handler-chain&gt;
              &lt;handler&gt;
                  &lt;handler-name&gt;LoggingSOAPHandler&lt;/handler-name&gt;
                  &lt;handler-class&gt;com.handler.LoggingSOAPHandler&lt;/handler-class&gt;
              &lt;/handler&gt;
          &lt;/handler-chain&gt;
      &lt;/handler-chains&gt;    
  &lt;/jaxws:bindings&gt;
  </code></pre>
  
  <p>wsimport command:</p>
  
  <pre><code>  &lt;property name="package"       value="com.ws"/&gt;
    &lt;property name="src"           value="docroot/WEB-INF/src"/&gt;
    &lt;property name="classes"       value="docroot/WEB-INF/classes"/&gt;
    &lt;property name="bindingfile"   value="docroot/WEB-INF/src/com/handler/handler-chain.xml"/&gt;
      &lt;target name="wsimport"&gt;
          &lt;exec executable="${jdk.home}/bin/wsimport"&gt;
            &lt;arg line="-keep -s ${src} -p ${package} -d ${classes} -b ${bindingfile} ${wsdl}"/&gt;
          &lt;/exec&gt;
        &lt;/target&gt;
  </code></pre>
  
  <p>When I run above wsimport command, all the stubs are created and the <code>@HandlerChain</code> annotation gets added to the stub service class as noted below:</p>
  
  <pre><code>@WebServiceClient(name = "TestService", targetNamespace = "http://webservice.com/", wsdlLocation = "http://test:8290/TEST/services/test?wsdl")
  @HandlerChain(file = "TestService_Service_handler.xml")
  public class TestService_Service
      extends Service
  {
      ...
  }
  </code></pre>
  
  <p>Here is the generated TestService_Service_handler.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;handler-chains xmlns="http://java.sun.com/xml/ns/javaee"&gt;
    &lt;handler-chain&gt;
      &lt;handler&gt;
        &lt;handler-name&gt;LoggingSOAPHandler&lt;/handler-name&gt;
        &lt;handler-class&gt;com.handler.LoggingSOAPHandler&lt;/handler-class&gt;
      &lt;/handler&gt;
    &lt;/handler-chain&gt;
  &lt;/handler-chains&gt;
  </code></pre>
  
  <p>Here is my <code>SOAPHandler</code>:</p>
  
  <pre><code>public class LoggingSOAPHandler implements SOAPHandler&lt;SOAPMessageContext&gt; {
  
      private static Logger _logger = LoggerFactory.getLogger(LoggingSOAPHandler.class);
  
      @Override
      public boolean handleMessage(SOAPMessageContext messageContext) {
  
          Boolean outboundProperty = (Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
  
          if (outboundProperty.booleanValue()) {
              _logger.info("\nOutbound message:");
          } else {
              _logger.info("\nInbound message:");
          }
          return true;
      }
  
      @Override
      public boolean handleFault(SOAPMessageContext context) {
          _logger.info("Client : handleFault()......");
          return false;
      }
  
      @Override
      public void close(MessageContext context) {
          _logger.info("Client : close()......");
  
      }
  
      @Override
      public Set&lt;QName&gt; getHeaders() {
          _logger.info("Client : getHeaders()......");
          return null;
      }
  }
  </code></pre>
  
  <p>When the webservice is called, handleMessage method doesn't get invoked at all.
  Any idea?<br>
  I'm using JAX-WS RI 2.2.4-b01 to generate the stubs.</p>