EndpointBuilder builder = new EndpointURIEndpointBuilder(endpoint);
builder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
OutboundEndpoint syncEndpoint = muleContext.getRegistry()
.lookupEndpointFactory()
.getOutboundEndpoint(builder);
MuleEvent dispatchEvent = new DefaultMuleEvent(message,
MessageExchangePattern.REQUEST_RESPONSE, session);
MuleMessage result = null;
MuleEvent resultEvent = syncEndpoint.process(dispatchEvent);
if (resultEvent != null)
{
result = resultEvent.getMessage();
}
if (result != null)
{
byte[] response = result.getPayloadAsBytes();
Message responseMessage = new Message(response);
msgContext.setResponseMessage(responseMessage);
}
else
{
logger
.warn("No response message was returned from synchronous call to: " + uri);
}
// remove temp file created for streaming
if (payload instanceof File)
{
((File)payload).delete();
}
}
else
{
MuleEvent dispatchEvent = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY,
session);
endpoint.process(dispatchEvent);
}
}
catch (Exception e)