ReportHeaderProcessed extends AbstractHandler { @Override public InvocationResponse invoke(final MessageContext msgCtx) throws AxisFault { final SOAPEnvelope env = msgCtx.getEnvelope(); if (env != null) { @SuppressWarnings("unchecked") final Iterator<OMElement> headers = env.getHeader().getChildElements(); while (headers.hasNext()) ((SOAPHeaderBlock) headers.next()).setProcessed(); } return InvocationResponse.CONTINUE; }  @Override InvocationResponse invoke(final MessageContext msgCtx);  }
@Test public void doProcessing() throws Exception { SOAPFactory omFactory = OMAbstractFactory.getSOAP12Factory(); final org.apache.axiom.soap.SOAPEnvelope envelope = omFactory.getDefaultEnvelope(); envelope.declareNamespace("http: envelope.declareNamespace("http: envelope.getHeader().addHeaderBlock(new QName("AFirstHeader", "http: envelope.getHeader().addHeaderBlock(new QName("AnotherHeader", "http: envelope.getHeader().addHeaderBlock(new QName("AndALastOne", "http: MessageContext mc = new MessageContext(); try { mc.setEnvelope(envelope); } catch (AxisFault axisFault) { fail(axisFault.getMessage()); } SOAPHeaderBlock h = null; for(Iterator hdrs = envelope.getHeader().getChildElements(); hdrs.hasNext(); ) { h = (SOAPHeaderBlock) hdrs.next(); assertFalse(h.isProcessed()); } try { Handler.InvocationResponse invokeResp = new ReportHeaderProcessed().invoke(mc); assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp); } catch (Exception e) { fail(e.getMessage()); } for(Iterator hdrs = envelope.getHeader().getChildElements(); hdrs.hasNext(); ) { h = (SOAPHeaderBlock) hdrs.next(); assertTrue(h.isProcessed()); } }