String sequencePropertyKey, StorageManager storageManager) throws AxisFault {
MessageContext referenceMessage = referenceRMMessage.getMessageContext();
if (referenceMessage == null)
throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.msgContextNotSet));
AxisOperation terminateOperation = referenceMessage.getAxisService().getOperation(new QName (Sandesha2Constants.RM_IN_OUT_OPERATION_NAME));
try {
if (terminateOperation==null)
terminateOperation = AxisOperationFactory.getAxisOperation(WSDL20_2004Constants.MEP_CONSTANT_OUT_ONLY);
} catch (AxisFault e1) {
throw new SandeshaException(e1.getMessage());
}
if (terminateOperation == null)
throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.terminateOpperationIsNull));
ConfigurationContext configCtx = referenceMessage.getConfigurationContext();
if (configCtx == null)
throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet));
MessageContext terminateMessage = SandeshaUtil.createNewRelatedMessageContext(referenceRMMessage,
terminateOperation);
OperationContext operationContext = terminateMessage.getOperationContext();
configCtx.registerOperationContext(terminateMessage.getMessageID(), operationContext); // to
// receive
// terminate
// sequence
// response
// messages
// correctly.
//using the Sandesha2 RMOutInOperation as the reference operation.
AxisOperation referenceOperation = referenceMessage.getAxisService()
.getOperation(new QName (Sandesha2Constants.RM_IN_OUT_OPERATION_NAME));
AxisOperation terminateMsgOperation = terminateMessage.getAxisOperation();
if (referenceOperation != null) {
terminateMsgOperation.setPhasesOutFlow(referenceOperation.getPhasesOutFlow());
terminateMsgOperation.setPhasesOutFaultFlow(referenceOperation.getPhasesOutFaultFlow());
terminateMsgOperation.setPhasesInFaultFlow(referenceOperation.getPhasesInFaultFlow());
terminateMsgOperation.setRemainingPhasesInFlow(referenceOperation.getRemainingPhasesInFlow());
}
String rmVersion = SandeshaUtil.getRMVersion(sequencePropertyKey, storageManager);
if (rmVersion == null)
throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotDecideRMVersion));
String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
initializeCreation(referenceMessage, terminateMessage);
if (!SpecSpecificConstants.isTerminateSequenceResponseRequired(rmVersion)) {
terminateMessage.setProperty(MessageContext.TRANSPORT_IN, null);
}
RMMsgContext terminateRMMessage = MsgInitializer.initializeMessage(terminateMessage);
if (terminateMessage == null)
throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.msgContextNotSet));
// setUpMessage(referenceMessage, terminateMessage);
SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(referenceMessage
.getEnvelope()));
terminateMessage.setMessageID(SandeshaUtil.getUUID());
AxisOperation referenceMsgOperation = referenceMessage.getAxisOperation();
if (referenceMsgOperation != null) {
ArrayList outPhases = referenceMsgOperation.getPhasesOutFlow();
if (outPhases != null) {
terminateOperation.setPhasesOutFlow(outPhases);
terminateOperation.setPhasesOutFaultFlow(outPhases);
}
}