// is
// synchronized
// with
// addressing.
SequencePropertyBean addressingNamespaceBean = new SequencePropertyBean(sequencePropertyKey,
Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, addressingNamespace);
seqPropMgr.insert(addressingNamespaceBean);
//setting the SOAPVersion Bean.
String SOAPVersion = firstAplicationMsgCtx.getOptions().getSoapVersionURI();
SequencePropertyBean SOAPVersionBean = new SequencePropertyBean (sequencePropertyKey,
Sandesha2Constants.SequenceProperties.SOAP_VERSION, SOAPVersion);
seqPropMgr.insert(SOAPVersionBean);
String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);
EndpointReference toEPR = firstAplicationMsgCtx.getTo();
String acksTo = (String) firstAplicationMsgCtx.getProperty(SandeshaClientConstants.AcksTo);
if (toEPR == null) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
throw new SandeshaException(message);
}
SequencePropertyBean toBean = new SequencePropertyBean(sequencePropertyKey,
Sandesha2Constants.SequenceProperties.TO_EPR, toEPR.getAddress());
SequencePropertyBean replyToBean = null;
SequencePropertyBean acksToBean = null;
if (firstAplicationMsgCtx.isServerSide()) {
// setting replyTo value, if this is the server side.
OperationContext opContext = firstAplicationMsgCtx.getOperationContext();
try {
MessageContext requestMessage = opContext
.getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
if (requestMessage == null) {
String message = SandeshaMessageHelper
.getMessage(SandeshaMessageKeys.cannotFindReqMsgFromOpContext);
log.error(message);
throw new SandeshaException(message);
}
EndpointReference replyToEPR = requestMessage.getTo(); // 'replyTo'
// of
// the
// response
// msg
// is
// the
// 'to'
// value
// of
// the
// req
// msg.
if (replyToEPR != null) {
replyToBean = new SequencePropertyBean(sequencePropertyKey,
Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, replyToEPR.getAddress());
acksToBean = new SequencePropertyBean(sequencePropertyKey,
Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, replyToEPR.getAddress());
} else {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.error(message);
throw new SandeshaException(message);
}
} catch (AxisFault e) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotFindReqMsgFromOpContext);
log.error(message);
log.error(e.getStackTrace());
throw new SandeshaException(message);
}
} else {
EndpointReference replyToEPR = firstAplicationMsgCtx.getReplyTo();
//setting replyTo and acksTo beans.
if (replyToEPR!=null)
replyToBean = new SequencePropertyBean(sequencePropertyKey,
Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, replyToEPR.getAddress());
//TODO set AcksToBean.
}
// Default value for acksTo is anonymous (this happens only for the
// client side)
if (acksTo == null) {
acksTo = anonymousURI;
}
acksToBean = new SequencePropertyBean(sequencePropertyKey, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,
acksTo);
// start the in listner for the client side, if acksTo is not anonymous.
if (!firstAplicationMsgCtx.isServerSide() && !anonymousURI.equals(acksTo)) {
String transportInProtocol = firstAplicationMsgCtx.getOptions().getTransportInProtocol();
if (transportInProtocol == null) {
throw new SandeshaException(SandeshaMessageHelper
.getMessage(SandeshaMessageKeys.cannotStartListenerForIncommingMsgs));
}
try {
ListenerManager listenerManager = firstAplicationMsgCtx.getConfigurationContext().getListenerManager();
TransportInDescription transportIn = firstAplicationMsgCtx.getConfigurationContext()
.getAxisConfiguration().getTransportIn(new QName(transportInProtocol));
// if acksTo is not anonymous start the in-transport
if (!listenerManager.isListenerRunning(transportIn.getName().getLocalPart())) {
listenerManager.addListener(transportIn, false);
}
} catch (AxisFault e) {
throw new SandeshaException(SandeshaMessageHelper.getMessage(
SandeshaMessageKeys.cannotStartTransportListenerDueToError, e.toString()), e);
}
}
SequencePropertyBean msgsBean = new SequencePropertyBean();
msgsBean.setSequencePropertyKey(sequencePropertyKey);
msgsBean.setName(Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES);
msgsBean.setValue("");
seqPropMgr.insert(msgsBean);
seqPropMgr.insert(toBean);
if (acksToBean != null)
seqPropMgr.insert(acksToBean);
if (replyToBean != null)
seqPropMgr.insert(replyToBean);
// saving transportTo value;
String transportTo = (String) firstAplicationMsgCtx.getProperty(MessageContextConstants.TRANSPORT_URL);
if (transportTo != null) {
SequencePropertyBean transportToBean = new SequencePropertyBean();
transportToBean.setSequencePropertyKey(sequencePropertyKey);
transportToBean.setName(Sandesha2Constants.SequenceProperties.TRANSPORT_TO);
transportToBean.setValue(transportTo);
seqPropMgr.insert(transportToBean);
}
// setting the spec version for the client side.
SequencePropertyBean specVerionBean = new SequencePropertyBean();
specVerionBean.setSequencePropertyKey(sequencePropertyKey);
specVerionBean.setName(Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
specVerionBean.setValue(specVersion);
seqPropMgr.insert(specVerionBean);
// updating the last activated time.
updateLastActivatedTime(sequencePropertyKey, storageManager);