String ret = null;
MessageContext mc = MessageContext.getCurrentContext();
// Verify the existence of in the input header
SOAPEnvelope env = mc.getRequestMessage().getSOAPEnvelope();
SOAPHeaderElement header = env.getHeaderByName("http://test.org/inputheader", "headerin");
if (header != null)
{
ret = header.getObjectValue().toString();
}
// add a different output header to the response
env = mc.getResponseMessage().getSOAPEnvelope();
SOAPHeaderElement hdr =
new SOAPHeaderElement("http://test.org/outputheader", "headerout", "outputvalue");
env.addHeader(hdr);
// just return the input header, so test can validate it
return ret;