2.16 Axis Message Handler

Refer to 2.17 SOAP Agent Message Handler.

Apache Axis allows custom message handlers to be created and deployed.

These handlers allow additional processing on the SOAP XML messages before transmission.

To determine the configuration name of your service, turn on LOG4J logging and run the SOAP Agent service once.

 

log4j.logger.org.apache.axis=DEBUG, FILE

log4j.additivity.org.apache.axis=false

 

 

Search the LOG4J.TXT file for the setTargetService string. The value within the brackets is the configuration service name.

 

[DEBUG] [message.SOAPBody] addBodyElement - Adding body element to message...

[DEBUG] [client.Call] invoke - Enter:  Call::invoke()

[DEBUG] [axis.MessageContext] setTargetService - MessageContext: setTargetService(MyServicePort)

 

Add a deployment service entry to the configuration file.

The handler type value is the custom Java handler class.

It is also possible to pass configuration parameters to the handler instance.

 

<service name="MyServicePort">

  <requestFlow>

    <handler type="java:com.acme.axis.handler.MyHandler">

      <parameter name="acme.keyword" value="value"/>

    </handler>

  </requestFlow>

</service>

 

 

The custom handler class needs to extend the 'org.apache.axis.handlers.BasicHandler' class.

 

package com.acme.axis.handler ;

 

import org.apache.axis.AxisFault ;

import org.apache.axis.MessageContext ;

 

import org.apache.axis.message.PrefixedQName ;

 

import org.apache.axis.handlers.BasicHandler ;

 

import org.w3c.dom.Node ;

import org.w3c.dom.NodeList ;

 

import javax.xml.soap.Name ;

import javax.xml.soap.SOAPPart ;

import javax.xml.soap.SOAPBody ;

import javax.xml.soap.SOAPElement ;

import javax.xml.soap.SOAPMessage ;

import javax.xml.soap.SOAPEnvelope ;

import javax.xml.soap.SOAPException ;

 

import javax.xml.rpc.handler.soap.SOAPMessageContext ;

 

public class MyHandler extends BasicHandler

{

    public void invoke ( MessageContext messageContext ) throws AxisFault

    {

         System.out.println ( "MyHandler: invoke" ) ;

 

         String value = (String)getOption ( "acme.keyword" ) ;

 

         modifyMessage ( messageContext ) ;

 

    }

}