}
try {
MessageContext messageOut = MessageHelper.cloneMessageContext(messageIn);
Options options = new Options();
options.setTo(new EndpointReference(serviceUrl));
if(messageIn.getSoapAction() != null) {
options.setAction(messageIn.getSoapAction());
} else {
if (messageIn.isSOAP11()) {
options.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, true);
} else {
Axis2MessageContext axis2smc = (Axis2MessageContext) messageOut;
org.apache.axis2.context.MessageContext axis2MessageCtx =
axis2smc.getAxis2MessageContext();
axis2MessageCtx.getTransportOut().addParameter(
new Parameter(HTTPConstants.OMIT_SOAP_12_ACTION, true));
}
}
//After setting all the options we need to find the MEP of the Message
org.apache.axis2.context.MessageContext axis2Ctx =
((Axis2MessageContext)messageOut).getAxis2MessageContext();
boolean outOnlyMessage = "true".equals(messageIn.getProperty(
SynapseConstants.OUT_ONLY)) || WSDL2Constants.MEP_URI_IN_ONLY.equals(
axis2Ctx.getOperationContext()
.getAxisOperation().getMessageExchangePattern());
// Here We consider all other Messages that evaluates to outOnlyMessage == false
// follows out in mep.
if(log.isDebugEnabled()) {
log.debug("Invoking service Url " + serviceUrl + " with Message" +
messageIn.getMessageID());
}
options.setProperty(
AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
//clean existing headers
// otherwise when retrying same header element will add multiple times
sc.removeHeaders();