EndpointReference acksToEPR = rmsBean.getAcksToEndpointReference();
if(acksToEPR == null){
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) {
// if the user has specified this sequence as a one way sequence it should not
// append the sequence offer.
if (!JavaUtils.isTrue(applicationMsgContext.getOptions().getProperty(
SandeshaClientConstants.ONE_WAY_SEQUENCE))) {
Parameter p = service.getParameter(Sandesha2Constants.SERVICE_CONTAINS_OUT_IN_MEPS);
if (p != null && p.getValue() != null) {
twoWayService = ((Boolean) p.getValue()).booleanValue();
if (log.isDebugEnabled()) log.debug("RMMsgCreator:: twoWayService " + twoWayService);
}
}
}
// Adding sequence offer - if present. We send an offer if the client has assigned an
// id, or if the service contains out-in MEPs
boolean autoOffer = twoWayService;
//There may not have been a way to confirm if an OUT_IN MEP is being used.
//Therefore doing an extra check to see what Axis is using. If it's OUT_IN then we must offer.
if(applicationMsgContext.getOperationContext() != null && applicationMsgContext.getOperationContext().getAxisOperation() != null){
if(applicationMsgContext.getOperationContext().getAxisOperation().getAxisSpecificMEPConstant() == org.apache.axis2.wsdl.WSDLConstants.MEP_CONSTANT_OUT_IN
|| applicationMsgContext.getOperationContext().getAxisOperation().getAxisSpecificMEPConstant() == org.apache.axis2.wsdl.WSDLConstants.MEP_CONSTANT_OUT_OPTIONAL_IN){
autoOffer = true;
}
}
// 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.
if(Sandesha2Constants.SPEC_2007_02.NS_URI.equals(rmNamespaceValue)) {
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);
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 the offeredEndpoint hasn't been set then use the acksTo of the RMSBean
if (offeredEndpoint==null) {
offeredEndpoint = rmsBean.getAcksToEndpointReference();
}
Endpoint endpoint = new Endpoint (offeredEndpoint, rmNamespaceValue, addressingNamespace);
offerPart.setEndpoint(endpoint);
}
createSequencePart.setSequenceOffer(offerPart);
}
EndpointReference toEPR = rmsBean.getToEndpointReference();
if (toEPR == null || toEPR.getAddress()==null) {
String message = SandeshaMessageHelper
.getMessage(SandeshaMessageKeys.toBeanNotSet);
throw new SandeshaException(message);
}
createSeqRMMsg.setTo(toEPR);
if(log.isDebugEnabled()) log.debug("RMMsgCreator:: toEPR=" + toEPR);
EndpointReference replyToEPR = rmsBean.getReplyToEndpointReference();
if(replyToEPR != null) {
replyToEPR = SandeshaUtil.getEPRDecorator(createSeqRMMsg.getConfigurationContext()).decorateEndpointReference(replyToEPR);
createSeqRMMsg.setReplyTo(replyToEPR);
if(log.isDebugEnabled()) log.debug("RMMsgCreator:: replyToEPR=" + replyToEPR);
}
AcksTo acksTo = new AcksTo(acksToEPR, rmNamespaceValue, addressingNamespace);
createSequencePart.setAcksTo(acksTo);
if(log.isDebugEnabled()) log.debug("RMMsgCreator:: acksTo=" + acksTo);
createSeqRMMsg.setCreateSequence(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 usesSeqStr = new UsesSequenceSTR();
usesSeqStr.toHeader(createSeqmsgContext.getEnvelope().getHeader());
}
// Ensure that the correct token will be used to secure the outbound create sequence message.