// This is a response. Check it for the session header.
Message msg = context.getResponseMessage();
if (msg == null)
return;
SOAPEnvelope env = msg.getSOAPPart().getAsSOAPEnvelope();
SOAPHeader header = env.getHeaderByName(SESSION_NS,
SESSION_LOCALPART);
if (header == null)
return;
// Got one!
try {
Long id = (Long)header.
getValueAsType(SOAPTypeMappingRegistry.XSD_LONG);
// Store it away.
AxisEngine engine = context.getAxisEngine();
engine.setOption(SESSION_ID, id);
} 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(JavaUtils.getMessage("noRequest00"));
SOAPEnvelope env = msg.getSOAPPart().getAsSOAPEnvelope();
SOAPHeader header = new SOAPHeader(SESSION_NS,
SESSION_LOCALPART,
id);
env.addHeader(header);
}
}