private void send(MessageContext msgctx) throws AxisFault {
// create the responseMessageContext and set that its related to the current outgoing
// message, so that it could be tied back to the original request even if the response
// envelope does not contain addressing headers
MessageContext responseMessageContext = new MessageContext();
responseMessageContext.setMessageID(msgctx.getMessageID());
responseMessageContext.setProperty(
SynapseConstants.RELATES_TO_FOR_POX, msgctx.getMessageID());
responseMessageContext.setOptions(options);
responseMessageContext.setServerSide(true);
addMessageContext(responseMessageContext);
AxisEngine.send(msgctx);
// did the engine receive a immediate synchronous response?
// e.g. sometimes the transport sender may listen for a syncronous reply
if (msgctx.getProperty(MessageContext.TRANSPORT_IN) != null) {
responseMessageContext.setOperationContext(msgctx.getOperationContext());
responseMessageContext.setAxisMessage(
msgctx.getOperationContext().getAxisOperation().
getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
responseMessageContext.setAxisService(msgctx.getAxisService());
responseMessageContext.setProperty(MessageContext.TRANSPORT_OUT,
msgctx.getProperty(MessageContext.TRANSPORT_OUT));
responseMessageContext.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
msgctx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO));
responseMessageContext.setProperty(
org.apache.synapse.SynapseConstants.ISRESPONSE_PROPERTY, Boolean.TRUE);
responseMessageContext.setTransportIn(msgctx.getTransportIn());
responseMessageContext.setTransportOut(msgctx.getTransportOut());
// If request is REST assume that the responseMessageContext is REST too
responseMessageContext.setDoingREST(msgctx.isDoingREST());
responseMessageContext.setProperty(MessageContext.TRANSPORT_IN,
msgctx.getProperty(MessageContext.TRANSPORT_IN));
responseMessageContext.setTransportIn(msgctx.getTransportIn());
responseMessageContext.setTransportOut(msgctx.getTransportOut());
// Options object reused above so soapAction needs to be removed so
// that soapAction+wsa:Action on response don't conflict
responseMessageContext.setSoapAction("");
if (responseMessageContext.getEnvelope() == null) {
// If request is REST we assume the responseMessageContext is
// REST, so set the variable
SOAPEnvelope resenvelope =
TransportUtils.createSOAPMessage(responseMessageContext);
if (resenvelope != null) {
responseMessageContext.setEnvelope(resenvelope);
AxisEngine.receive(responseMessageContext);
if (responseMessageContext.getReplyTo() != null) {
sc.setTargetEPR(responseMessageContext.getReplyTo());
}
complete(msgctx);
} else {
throw new AxisFault(