if (responseMessageContext==null || responseMessageContext.getEnvelope()==null) {
if (responseMessageContext==null)
responseMessageContext = new MessageContext();
OperationContext requestMsgOpCtx = msgCtx.getOperationContext();
responseMessageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, requestMsgOpCtx
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING));
responseMessageContext.setProperty(Constants.Configuration.CONTENT_TYPE, requestMsgOpCtx
.getProperty(Constants.Configuration.CONTENT_TYPE));
responseMessageContext.setProperty(HTTPConstants.MTOM_RECEIVED_CONTENT_TYPE, requestMsgOpCtx
.getProperty(HTTPConstants.MTOM_RECEIVED_CONTENT_TYPE));
// responseMessageContext.setOperationContext(requestMsgOpCtx);
// if ( !requestMsgOpCtx.isComplete()) {
// requestMsgOpCtx.addMessageContext(responseMessageContext);
// }
responseMessageContext.setAxisOperation(msgCtx.getAxisOperation());
//If the response MsgCtx was not available Axis2 would hv put the transport info into a
//HashMap, getting the data from it.
HashMap transportInfoMap = (HashMap) msgCtx.getProperty(Constants.Configuration.TRANSPORT_INFO_MAP);
if (transportInfoMap != null) {
responseMessageContext.setProperty(Constants.Configuration.CONTENT_TYPE,
transportInfoMap.get(Constants.Configuration.CONTENT_TYPE));
responseMessageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
transportInfoMap.get(Constants.Configuration.CHARACTER_SET_ENCODING));
}
responseMessageContext.setConfigurationContext(msgCtx.getConfigurationContext());
responseMessageContext.setTransportIn(msgCtx.getTransportIn());
responseMessageContext.setTransportOut(msgCtx.getTransportOut());
responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgCtx
.getProperty(MessageContext.TRANSPORT_IN));
//we will not be setting the operation context here since this msgs may not be an application reply.
//we let other dispatchers find it.
responseMessageContext.setServiceContext(msgCtx.getServiceContext());
responseMessageContext.setServiceGroupContext(msgCtx.getServiceGroupContext());
responseMessageContext.setProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY,
msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY));
// If request is REST we assume the responseMessageContext is REST,
// so set the variable
responseMessageContext.setDoingREST(msgCtx.isDoingREST());
resenvelope = responseMessageContext.getEnvelope();
try {
// MessageContext is modified in TransportUtils.createSOAPMessage(). It might be used by axis.engine or handler.
// To catch the modification and pass it to engine or handler, resenvelope is created by responseMessageContext.
if (resenvelope==null) {
//We try to build the response out of the transport stream.
resenvelope = TransportUtils.createSOAPMessage(responseMessageContext);
responseMessageContext.setEnvelope(resenvelope);
syncResponseBuilt = true;
}
} catch (AxisFault e) {
//Cannot find a valid SOAP envelope.
if (log.isErrorEnabled() ) {
log.error (SandeshaMessageHelper
.getMessage(SandeshaMessageKeys.soapEnvNotSet));
log.error ("Caught exception", e);
}
return true;
}
//If addressing is disabled we will be adding this message simply as the application response of the request message.
Boolean addressingDisabled = (Boolean) msgCtx.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
if (addressingDisabled!=null && Boolean.TRUE.equals(addressingDisabled)) {
// If the AxisOperation object doesn't have a message receiver, it means that this was
// an out only op where we have added an ACK to the response. Set the requestMsgOpCtx to
// be the RMIn
OperationContext responseMsgOpCtx = requestMsgOpCtx;
if (requestMsgOpCtx.getAxisOperation().getMessageReceiver() == null) {
// Generate a new RM In Only operation
ServiceContext serviceCtx = responseMessageContext.getServiceContext();
AxisOperation op = msgCtx.getAxisService().getOperation(Sandesha2Constants.RM_IN_ONLY_OPERATION);