The best start was to check Axis guide on: Apache-Axis Reference Guide where you will have an overview of the work flow.
To configure handlers to be trigger from the client side you need to do the following:
1- Create handler class basically something similar to the following:
package mypackge;
import javax.xml.soap.SOAPException;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.message.SOAPHeader;
import org.apache.axis.message.SOAPHeaderElement;
public class SoapHeaderConsumerHandler
extends BasicHandler
{
public void invoke(MessageContext messageContext)
throws AxisFault
{
// Your logic for request or response handling goes here.
// Basically you need to make use of the parameter
// messageContext where you can access the soap header and body tags.
}
}
2- Create the client-config.wsdd
file. it will look like the following:
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<globalConfiguration>
<responseFlow>
<handler name="log" type="java:mypackge.SoapHeaderConsumerHandler"/>
</responseFlow>
</globalConfiguration>
<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
</deployment>
You can see that I am using only handlers for the incoming response from the server side. So when ever the client application receive a response from the server the handler class SoapHeaderConsumerHandler
will be triggered and the method invoke will be called by default.
Note: if you want to access the outgoing request before send it to the server you need to add extra tag for <requestFlow>
to add request handler.
Check Deployment(WSDD) Reference from Axis guide:
3- Where to place the client-config.wsdd
file ?
You should place the .wsdd
file in the working directory. You can easily find out the working directory location using :
System.out.println("Working Directory = " + System.getProperty("user.dir"));
Source: Getting the Current Working Directory in Java
UPDATE:
I found out that it is not necessary to put the client-config.wsdd
file in the working directory. You can specify the path of this file in your code as follow:
System.setProperty("axis.ClientConfigFile", "[Path goes here]\\client-config.wsdd");
You just need to place the .wsdd
file there.
Extra Useful Links:
Where to place the client-config.wsdd file in Railo
V Axis handler This is an example for the server side handlers.
Dealing with SOAP Headers in Axis