W3CDOMStreamWriter domWriter = (W3CDOMStreamWriter)message.getContent(XMLStreamWriter.class);
XMLStreamWriter origWriter = (XMLStreamWriter)message
.get(LogicalHandlerOutInterceptor.ORIGINAL_WRITER);
HandlerChainInvoker invoker = getInvoker(message);
LogicalMessageContextImpl lctx = new LogicalMessageContextImpl(message);
invoker.setLogicalMessageContext(lctx);
boolean requestor = isRequestor(message);
XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER");
SOAPMessage origMessage = null;
if (reader != null) {
origMessage = message.getContent(SOAPMessage.class);
message.setContent(XMLStreamReader.class, reader);
message.removeContent(SOAPMessage.class);
} else if (domWriter.getCurrentFragment() != null) {
DocumentFragment frag = domWriter.getCurrentFragment();
Node nd = frag.getFirstChild();
while (nd != null && !(nd instanceof Element)) {
nd = nd.getNextSibling();
}
Source source = new DOMSource(nd);
message.setContent(Source.class, source);
message.setContent(XMLStreamReader.class,
new W3CDOMStreamReader(domWriter.getCurrentFragment()));
} else if (domWriter.getDocument().getDocumentElement() != null) {
Source source = new DOMSource(domWriter.getDocument());
message.setContent(Source.class, source);
message.setContent(XMLStreamReader.class,
StaxUtils.createXMLStreamReader(domWriter.getDocument()));
}
if (!invoker.invokeLogicalHandlers(requestor, lctx)) {
if (requestor) {
// client side - abort
message.getInterceptorChain().abort();
if (!message.getExchange().isOneWay()) {
Endpoint e = message.getExchange().get(Endpoint.class);