[Ws Wiki] Update of "FrontPage/Axis/AxisClientSetHTTPHead ers" by FlorianKirchhoff

Apache Wiki <[email protected]>
Newsgroups gmane.comp.apache.webservices.general
Message-ID <[email protected]>
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.

The "FrontPage/Axis/AxisClientSetHTTPHeaders" page has been changed by FlorianKirchhoff.
http://wiki.apache.org/ws/FrontPage/Axis/AxisClientSetHTTPHeaders

--------------------------------------------------

New page:
Q: How do I setup HTTP headers in Axis clients?

A: Set the appropriate Hashtable entry in the MessageContext in a Handler:

{{{
package yourpackage;
import java.util.Hashtable;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.transport.http.HTTPConstants;
public class HTTPHeaderHandler extends BasicHandler {
  @Override
  public void invoke(MessageContext ctx) throws AxisFault {
    Hashtable ht = (Hashtable)ctx.getProperty(HTTPConstants.REQUEST_HEADERS);
    if(ht == null) {
      ht = new Hashtable();
    }
    ht.put("test", "test");
    ctx.setProperty(HTTPConstants.REQUEST_HEADERS, ht);
  }
}
}}}
The next step is to configure the handler in client-config.wsdd:

{{{
<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultClientConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <globalConfiguration>
  <parameter name="disablePrettyXML" value="true" />
  <parameter name="enableNamespacePrefixOptimization" value="false" />
 </globalConfiguration>
 <handler type="java:yourpackage.HTTPHeaderHandler" name="HTTPHeaderHandler" />
 <transport name="http"
  pivot="java:org.apache.axis.transport.http.HTTPSender">
  <requestFlow>
   <handler type="HTTPHeaderHandler" />
  </requestFlow>
 </transport>
 <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender" />
 <transport name="java"  pivot="java:org.apache.axis.transport.java.JavaSender" />
</deployment>
}}}
You can find details of how to configure a Handler in AxisClientConfiguration and how to ensure your client code picks up your client-config.wsdd in AxisClientConfiguration.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.