title: Handler to add HTTP headers to HTTP request not invoked when using Axis Client API
body: <p>I am using the Axis API to access Axis HTTP server.
  The documentation of the API can be found <a href="http://ws.apache.org/axis/java/apiDocs/index.html" rel="noreferrer">here</a>.</p>
  
  <p>I am using the following code to add handlers to the server. <code>service</code> is of type java.xml.rpc.Service</p>
  
  <pre><code>    HandlerRegistry registry = service.getHandlerRegistry();
      QName serviceName = new QName(url, "MyServiceClass");
  
      List&lt;HandlerInfo&gt; handlerChain = new ArrayList&lt;HandlerInfo&gt;();
      HandlerInfo handlerInfo = new HandlerInfo(MyHandler.class, null, null);
      handlerChain.add(handlerInfo);
      registry.setHandlerChain(serviceName, handlerChain);
  </code></pre>
  
  <p>I know that the service name is correct as I am getting the correct output in subsequent calls to the service object.</p>
  
  <p>Somehow the handler is not being invoked. Here is the Handler class.
  My intention is to <strong>add custom headers to the HTTP request</strong> before forwarding the request to the server.</p>
  
  <pre><code>import javax.xml.namespace.QName;
  import org.apache.axis.AxisFault;
  import org.apache.axis.MessageContext;
  import org.apache.axis.handlers.BasicHandler;
  
  public class MyHandler extends BasicHandler {
  
      @Override
      public void init() {
          System.out.println("init called");
          super.init();
          System.out.println("init called");
      }
  
      @Override
      public void cleanup() {
          super.cleanup();
          System.out.println("cleanup called");
      }
  
      @Override
      public void invoke(MessageContext mc) throws AxisFault {
          System.out.println("invoke called");
      }
  
      public QName[] getHeaders() {
          System.out.println("getHeaders");
          return new QName[1];
      }
  }
  </code></pre>
  
  <p>What is wrong with the above code?</p>
  
  <p>Is there any other way to modify HTTP Headers using Apache Axis API?</p>