* @return Returns MessageContext.
* @throws AxisFault Sends the message using a two way transport and waits for a response
*/
protected MessageContext send(MessageContext msgctx) throws AxisFault {
AxisEngine engine = new AxisEngine(msgctx.getConfigurationContext());
// create the responseMessageContext
MessageContext responseMessageContext = new MessageContext();
// This is a hack - Needs to change
responseMessageContext.setOptions(options);
responseMessageContext.setServerSide(false);
responseMessageContext.setMessageID(msgctx.getMessageID());
addMessageContext(responseMessageContext);
responseMessageContext.setServiceContext(msgctx.getServiceContext());
responseMessageContext.setAxisMessage(
axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
//sending the message
engine.send(msgctx);
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, msgctx.getEnvelope().getNamespace()
.getNamespaceURI());
if (resenvelope != null) {
responseMessageContext.setEnvelope(resenvelope);
} else {
throw new AxisFault(Messages
.getMessage("blockingInvocationExpectsResponse"));
}
}
SOAPEnvelope resenvelope = responseMessageContext.getEnvelope();
if (resenvelope != null) {
if (resenvelope.getBody().hasFault()) {
SOAPFault soapFault = resenvelope.getBody().getFault();
//we need to call engine.receiveFault
engine = new AxisEngine(msgctx.getConfigurationContext());
engine.receiveFault(responseMessageContext);
if (options.isExceptionToBeThrownOnSOAPFault()) {
// does the SOAPFault has a detail element for Excpetion
throw new AxisFault(soapFault.getCode(), soapFault.getReason(),
soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
}
} else {
engine = new AxisEngine(msgctx.getConfigurationContext());
engine.receive(responseMessageContext);
if (responseMessageContext.getReplyTo() != null) {
sc.setTargetEPR(responseMessageContext.getReplyTo());
}
}
}