header = factory.createSOAPHeader(messageContext.getEnvelope());
}
if (otargetSession != null && otargetSession instanceof MutableEndpoint) {
WSAEndpoint targetEpr = EndpointFactory.convertToWSA((MutableEndpoint) otargetSession);
OMElement to = factory.createSOAPHeaderBlock("To", wsAddrNS);
header.addChild(to);
to.setText(targetEpr.getUrl());
String action = messageContext.getSoapAction();
OMElement wsaAction = factory.createSOAPHeaderBlock("Action", wsAddrNS);
header.addChild(wsaAction);
wsaAction.setText(action);
// we only set the ReplyTo and MessageID headers if doing Request-Response
org.apache.axis2.addressing.EndpointReference replyToEpr = messageContext.getReplyTo();
if (replyToEpr != null) {
OMElement replyTo = factory.createSOAPHeaderBlock("ReplyTo", wsAddrNS);
OMElement address = factory.createOMElement("Address", wsAddrNS);
replyTo.addChild(address);
header.addChild(replyTo);
address.setText(replyToEpr.getAddress());
String messageId = messageContext.getMessageID();
OMElement messageIdElem = factory.createSOAPHeaderBlock("MessageID", wsAddrNS);
header.addChild(messageIdElem);
messageIdElem.setText(messageId);
}
if (targetEpr.getSessionId() != null) {
OMElement session = factory.createSOAPHeaderBlock("session", odeSessNS);
header.addChild(session);
session.setText(targetEpr.getSessionId());
}
__log.debug("Sending stateful TO epr in message header using session " + targetEpr.getSessionId());
}
if (ocallbackSession != null && ocallbackSession instanceof MutableEndpoint) {
WSAEndpoint callbackEpr = EndpointFactory.convertToWSA((MutableEndpoint) ocallbackSession);
OMElement callback = factory.createSOAPHeaderBlock("callback", odeSessNS);
header.addChild(callback);
OMElement address = factory.createOMElement("Address", wsAddrNS);
callback.addChild(address);
address.setText(callbackEpr.getUrl());
if (callbackEpr.getSessionId() != null) {
OMElement session = factory.createOMElement("session", odeSessNS);
session.setText(callbackEpr.getSessionId());
callback.addChild(session);
}
__log.debug("Sending stateful FROM epr in message header using session " + callbackEpr.getSessionId());
}
__log.debug("Sending a message containing wsa endpoints in headers for session passing.");
__log.debug(messageContext.getEnvelope().toString());