}
if (addressingNamespace==null)
addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE; //defaults to Final. Make sure this is synchronized with addressing.
SequencePropertyBean addressingNamespaceBean = new SequencePropertyBean (
internalSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,addressingNamespace);
seqPropMgr.insert(addressingNamespaceBean);
String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);
EndpointReference toEPR = firstAplicationMsgCtx.getTo();
String acksTo = (String) firstAplicationMsgCtx
.getProperty(SandeshaClientConstants.AcksTo);
if (toEPR == null) {
String message = "WS-Addressing To is null";
log.debug(message);
throw new SandeshaException(message);
}
SequencePropertyBean toBean = new SequencePropertyBean(internalSequenceId,
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 = "Cannot find the request message from the operation context";
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 (internalSequenceId,Sandesha2Constants.SequenceProperties.REPLY_TO_EPR,replyToEPR.getAddress());
acksToBean = new SequencePropertyBean (internalSequenceId,Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,replyToEPR.getAddress());
} else {
String message = "To EPR is not present in the request message. Need this information to set acksTo & replyTo value of reply messages";
log.error(message);
throw new SandeshaException (message);
}
} catch (AxisFault e) {
String message = "Cannot get request message from the operation context";
log.error(message);
log.error(e.getStackTrace());
throw new SandeshaException (message);
}
}
//Default value for acksTo is anonymous (this happens only for the client side)
if (acksTo==null) {
acksTo = anonymousURI;
}
acksToBean = new SequencePropertyBean(
internalSequenceId, 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 ("You must mention the transport in protocol for getting async acknowledgement messages");
}
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 ("Could not stast the transport listner",e);
}
}
SequencePropertyBean msgsBean = new SequencePropertyBean();
msgsBean.setSequenceID(internalSequenceId);
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.setSequenceID(internalSequenceId);
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.setSequenceID(internalSequenceId);
specVerionBean.setName(Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
specVerionBean.setValue(specVersion);
seqPropMgr.insert(specVerionBean);
//updating the last activated time.
updateLastActivatedTime(internalSequenceId,configurationContext);