// This is a response. Check it for the session header.
Message msg = context.getResponseMessage();
if (msg == null)
return;
SOAPEnvelope env = msg.getSOAPEnvelope();
SOAPHeaderElement header = env.getHeaderByName(SESSION_NS,
SESSION_LOCALPART);
if (header == null)
return;
// Got one!
try {
Long id = (Long)header.
getValueAsType(Constants.XSD_LONG);
// Store it away.
AxisEngine engine = context.getAxisEngine();
engine.setOption(SESSION_ID, id);
// Note that we processed this header!
header.setProcessed(true);
} catch (Exception e) {
throw AxisFault.makeFault(e);
}
} else {
AxisEngine engine = context.getAxisEngine();
Long id = (Long)engine.getOption(SESSION_ID);
if (id == null)
return;
// We have a session ID, so insert the header
Message msg = context.getRequestMessage();
if (msg == null)
throw new AxisFault(Messages.getMessage("noRequest00"));
SOAPEnvelope env = msg.getSOAPEnvelope();
SOAPHeaderElement header = new SOAPHeaderElement(SESSION_NS,
SESSION_LOCALPART,
id);
env.addHeader(header);
}
}