I am using the Axis API to access Axis HTTP server. The documentation of the API can be found here.
I am using the following code to add handlers to the server.
Okie. This should do the trick :
1 - Create a wsdd file (say /tmp/test.wsdd
) containing this :
2 - Ensure all axis libs are in your class path and then run :
java org.apache.axis.utils.Admin client /tmp/test.wsdd
3 - Step 2 will generate a client-config.wsdd. Copy this to your project and ensure it will be in the class path when the project is run.
4 - ALL webservice calls (via Http transport) will route via the TestHandler1 class
Here is my TestHandler1 class (a slight modification of ur handler to access the MIME headers) :
package axistest;
import javax.xml.namespace.QName;
import javax.xml.soap.MimeHeaders;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
public class TestHandler1 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");
System.out.println("=----------------------------------=");
MimeHeaders mimeHeaders = mc.getMessage().getMimeHeaders();
mimeHeaders.addHeader("X-Test", "Hello");
System.out.println("Headers : \n " + mimeHeaders);
}
public QName[] getHeaders() {
System.out.println("getHeaders");
return new QName[1];
}
}
when I run this on my box, I see that these handler methods are being invoked :
- Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
init called
init called
invoke called
=----------------------------------=
Headers :
org.apache.axis.message.MimeHeaders@761eec35
.
.
.