public class LogHandler extends BasicHandler { public void invoke (MessageContext msgContext) throws AxisFault { /** Log an access each time we get invoked. */ try { Handler serviceHandler = msgContext.getService();
Integer numAccesses = (Integer)serviceHandler.getOption("accesses"); if (numAccesses == null) numAccesses = new Integer(0); numAccesses = new Integer (numAccesses.intValue() + 1); Date date = new Date(); String result = date + ": service " + msgContext.getTargetService() + " accessed " + numAccesses + " time(s)."; serviceHandler.setOption ("accesses", numAccesses); System.out.println(result); } catch (Exception e) { throw AxisFault.makeFault(e); } } }