acksToEPR = new EndpointReference(acksToAddress);
} else {
acksToEPR = new EndpointReference(SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace));
}
CreateSequence createSequencePart = new CreateSequence(rmNamespaceValue);
// Check if this service includes 2-way operations
boolean twoWayService = false;
AxisService service = applicationMsgContext.getAxisService();
if(service != null) {
Parameter p = service.getParameter(Sandesha2Constants.SERVICE_CONTAINS_OUT_IN_MEPS);
if(p != null && p.getValue() != null) {
twoWayService = ((Boolean) p.getValue()).booleanValue();
}
}
// Adding sequence offer - if present. We send an offer if the client has assigned an
// id, or if we are using WS-RM 1.0 and the service contains out-in MEPs
boolean autoOffer = false;
if(Sandesha2Constants.SPEC_2005_02.NS_URI.equals(rmNamespaceValue)) {
autoOffer = twoWayService;
} else {
// We also do some checking at this point to see if MakeConection is required to
// enable WS-RM 1.1, and write a warning to the log if it has been disabled.
SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(context.getAxisConfiguration());
if(twoWayService && !policy.isEnableMakeConnection()) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.makeConnectionWarning);
log.warn(message);
}
}
String offeredSequenceId = (String) applicationMsgContext.getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID);
if(autoOffer ||
(offeredSequenceId != null && offeredSequenceId.length() > 0)) {
if (offeredSequenceId == null || offeredSequenceId.length() == 0) {
offeredSequenceId = SandeshaUtil.getUUID();
}
SequenceOffer offerPart = new SequenceOffer(rmNamespaceValue);
Identifier identifier = new Identifier(rmNamespaceValue);
identifier.setIndentifer(offeredSequenceId);
offerPart.setIdentifier(identifier);
createSequencePart.setSequenceOffer(offerPart);
if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(rmNamespaceValue)) {
// We are going to send an offer, so decide which endpoint to include
EndpointReference offeredEndpoint = (EndpointReference) applicationMsgContext.getProperty(SandeshaClientConstants.OFFERED_ENDPOINT);
if (offeredEndpoint==null) {
EndpointReference replyTo = applicationMsgContext.getReplyTo(); //using replyTo as the Endpoint if it is not specified
if (replyTo!=null) {
offeredEndpoint = SandeshaUtil.cloneEPR(replyTo);
}
}
// Finally fall back to using an anonymous endpoint
if (offeredEndpoint==null) {
offeredEndpoint = new EndpointReference(SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace));
}
Endpoint endpoint = new Endpoint (offeredEndpoint, rmNamespaceValue, addressingNamespace);
offerPart.setEndpoint(endpoint);
}
}
String to = rmsBean.getToEPR();
String replyTo = rmsBean.getReplyToEPR();
if (to == null) {
String message = SandeshaMessageHelper
.getMessage(SandeshaMessageKeys.toBeanNotSet);
throw new SandeshaException(message);
}
// TODO store and retrieve a full EPR instead of just the address.
EndpointReference toEPR = new EndpointReference(to);
createSeqRMMsg.setTo(toEPR);
if(replyTo != null) {
EndpointReference replyToEPR = new EndpointReference(replyTo);
createSeqRMMsg.setReplyTo(replyToEPR);
}
AcksTo acksTo = new AcksTo(acksToEPR, rmNamespaceValue, addressingNamespace);
createSequencePart.setAcksTo(acksTo);
createSeqRMMsg.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ, createSequencePart);
// Find the token that should be used to secure this new sequence. If there is a token, then we
// save it in the properties so that the caller can store the token within the create sequence
// bean.
SecurityManager secMgr = SandeshaUtil.getSecurityManager(context);
SecurityToken token = secMgr.getSecurityToken(applicationMsgContext);
if(token != null) {
OMElement str = secMgr.createSecurityTokenReference(token, createSeqmsgContext);
createSequencePart.setSecurityTokenReference(str);
createSeqRMMsg.setProperty(Sandesha2Constants.MessageContextProperties.SECURITY_TOKEN, token);
// If we are using token based security, and the 1.1 spec level, then we
// should introduce a UsesSequenceSTR header into the message.
if(createSequencePart.getNamespaceValue().equals(Sandesha2Constants.SPEC_2007_02.NS_URI)) {
UsesSequenceSTR header = new UsesSequenceSTR(null, Sandesha2Constants.SPEC_2007_02.NS_URI);
header.toSOAPEnvelope(createSeqmsgContext.getEnvelope());
}
// Ensure that the correct token will be used to secure the outbound create sequence message.