LOG.info("Reverse processing inbound message, exception: " + inboundException);
}
handlerInvoker.setOutbound();
ObjectMessageContext replyObjectCtx = objectCtx;
if (null == replyObjectCtx) {
replyObjectCtx = binding.createObjectContext();
}
replyObjectCtx.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.TRUE);
if (null != inboundException) {
replyObjectCtx.setException(inboundException);
}
// If protocol handlers were invoked inbound, then also invoke them
// outbound - except when message is oneway.
// TODO: relax this restriction to allow outbound processing of system
// handlers.
if (!logicalChainTraversed
&& state.value() >= ServerRequestState.LOGICAL_HANDLERS_INVOKED.value()
&& !isOneway()) {
// Protocol and runtime exceptions have already been caught by
// handler invoker and stored in the object context.
handlerInvoker.invokeLogicalHandlers(isRequestor(), replyObjectCtx);
}
// If on the inbound path we managed to construct a binding message
// context use it - otherwise create a new one.
MessageContext replyBindingCtx = bindingCtx;
if (null == replyBindingCtx) {
bindingCtx = binding.getBindingImpl().createBindingMessageContext(replyObjectCtx);
replyBindingCtx = bindingCtx;
} else if (null != replyObjectCtx) {
replyBindingCtx.putAll(replyObjectCtx);
}
// The following will only succeed if we have a data binding callback.
if (handlerInvoker.faultRaised(replyObjectCtx)) {
LOG.fine("Marshalling fault.");
marshalFault(replyObjectCtx, replyBindingCtx);
} else if (null != replyObjectCtx.get(ObjectMessageContext.MESSAGE_PAYLOAD)
|| state.value() >= ServerRequestState.DISPATCHED.value()
|| null != replyObjectCtx.get(ObjectMessageContext.METHOD_RETURN)) {
LOG.fine("Marshalling.");
marshal(replyObjectCtx, replyBindingCtx);
}
// If protocol handlers were invoked inbound, then also invoke them
// outbound - except when message is oneway.
// TODO: relax this restriction to allow outbound processing of system
// handlers.
// Note we may not be able to find out if the message is oneway (in case where
// inbound processing failed while invoking stream handlers).
if (state.value() >= ServerRequestState.PROTOCOL_HANDLERS_INVOKED.value() && !isOneway()) {
// Protocol and runtime exceptions have already been caught by
// handler invoker and stored in binding context
// As marshalling took place prior to invoking the
// protocol handlers we need to go back and marshal this fault.
handlerInvoker.invokeProtocolHandlers(isRequestor(), replyBindingCtx);
if (handlerInvoker.faultRaised(replyBindingCtx)
&& !binding.getBindingImpl().hasFault(replyBindingCtx)) {
LOG.fine("Marshalling fault raised by protocol handlers.");
replyObjectCtx.setException((Exception)replyBindingCtx.get(
ObjectMessageContext.METHOD_FAULT));
marshalFault(replyObjectCtx, replyBindingCtx);
}
}