}
if (endpoint instanceof ServiceAdapter) {
log.debug("Endpoint is a ServiceAdapter so message will be invoked");
//prepare an ack message
AcknowledgeMessage result = new AcknowledgeMessage();
result.setClientId(msg.getClientId());
result.setCorrelationId(msg.getMessageId());
result.setDestination(msg.getDestination());
result.setHeaders(headers);
//get the adapter
ServiceAdapter adapter = (ServiceAdapter) endpoint;
//log.debug("Invoke: {}", adapter.invoke(msg));
Object o = adapter.invoke(msg);
//the result of the invocation will make up the message body
//AsyncMessage ext = new AsyncMessage();
//ext.setClientId(msg.getClientId());
//ext.setCorrelationId(result.getMessageId());
//ext.setBody(o);
result.setBody(new Object[]{o});
return result;
} else {
log.error("Unknown Flex compatibility request: {}", msg);
String errMsg = String.format("Don't know how to handle %s", msg);
return returnError(msg, "notImplemented", errMsg, errMsg);