} else {
if (source instanceof RuntimeEndpointReference) {
msg.setTo(((RuntimeEndpointReference)source).getTargetEndpoint());
}
}
Invoker headInvoker = chain.getHeadInvoker();
Operation operation = null;
if(source instanceof RuntimeEndpoint) {
// [rfeng] We cannot use the targetOperation from the binding invocation chain.
// For each method, we need to find the matching operation so that we can set the operation on to the message
for (InvocationChain c : source.getInvocationChains()) {
Operation op = c.getTargetOperation();
if (method.getName().equals(op.getName())) {
operation = op;
break;
}
}
} else {
operation = chain.getTargetOperation();
}
msg.setOperation(operation);
msg.setBody(args);
Message msgContext = ThreadMessageContext.getMessageContext();
// Deal with header information that needs to be copied from the message context to the new message...
transferMessageHeaders( msg, msgContext);
ThreadMessageContext.setMessageContext(msg);
// If there is a supplied message ID, place its value into the Message Header under "MESSAGE_ID"
if( msgID != null ){
msg.getHeaders().put("MESSAGE_ID", msgID);
} // end if
try {
// dispatch the source down the chain and get the response
Message resp = headInvoker.invoke(msg);
Object body = resp.getBody();
if (resp.isFault()) {
throw (Throwable)body;
}
return body;