// default addressing version
String addressingNamespace = (String) msgCtx.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
if (addressingNamespace == null && !msgCtx.isServerSide())
addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE;
RMElements elements = new RMElements(addressingNamespace);
if (msgCtx.getEnvelope()!=null)
elements.fromSOAPEnvelope(msgCtx.getEnvelope(), msgCtx.getWSAAction());
String rmNamespace = null;
if (elements.getCreateSequence() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ, elements.getCreateSequence());
rmNamespace = elements.getCreateSequence().getNamespaceValue();
}
if (elements.getCreateSequenceResponse() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE, elements
.getCreateSequenceResponse());
rmNamespace = elements.getCreateSequenceResponse().getNamespaceValue();
}
if (elements.getSequence() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, elements.getSequence());
rmNamespace = elements.getSequence().getNamespaceValue();
}
//In case of ack messages RM Namespace is decided based on the sequenceId of the last
//sequence Ack. In other words Sandesha2 does not expect to receive two SequenceAcknowledgements
//of different RM specifications in the same incoming message
for (Iterator iter = elements.getSequenceAcknowledgements();iter.hasNext();) {
SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) iter.next();
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT, sequenceAck);
rmNamespace = sequenceAck.getNamespaceValue();
}
if (elements.getTerminateSequence() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ, elements.getTerminateSequence());
rmNamespace = elements.getTerminateSequence().getNamespaceValue();
}
if (elements.getTerminateSequenceResponse() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE, elements
.getTerminateSequenceResponse());
rmNamespace = elements.getTerminateSequenceResponse().getNamespaceValue();
}
//In case of ack request messages RM Namespace is decided based on the sequenceId of the last
//ack request.
for (Iterator iter = elements.getAckRequests();iter.hasNext();) {
AckRequested ackRequest = (AckRequested) iter.next();
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST, ackRequest);
rmNamespace = ackRequest.getNamespaceValue();
}
if (elements.getCloseSequence() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE, elements.getCloseSequence());
rmNamespace = elements.getCloseSequence().getNamespaceValue();
}
if (elements.getCloseSequenceResponse() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE, elements
.getCloseSequenceResponse());
rmNamespace = elements.getCloseSequenceResponse().getNamespaceValue();
}
if (elements.getUsesSequenceSTR() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.USES_SEQUENCE_STR, elements
.getUsesSequenceSTR());
}
if (elements.getMakeConnection() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.MAKE_CONNECTION,
elements.getMakeConnection());
String makeConnectionNamespace = elements.getMakeConnection().getNamespaceValue();
if (Sandesha2Constants.SPEC_2007_02.MC_NS_URI.equals(makeConnectionNamespace))
rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
}
if (elements.getMessagePending() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.MESSAGE_PENDING,
elements.getMessagePending());
String makeConnectionNamespace = elements.getMessagePending().getNamespaceValue();
if (Sandesha2Constants.SPEC_2007_02.MC_NS_URI.equals(makeConnectionNamespace))
rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
}
if (elements.getSequenceFault() != null) {
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE_FAULT,
elements.getSequenceFault());
}
if (rmNamespace!=null)
rmMsgContext.setRMNamespaceValue(rmNamespace);