in cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationOutputStream.java [75:143]
private void commitOutputMessage() throws IOException {
try {
if (inMessage.getExchange().isOneWay()) {
return;
} else {
InputStream bais = getInputStream();
Exchange xchng = inMessage.get(Exchange.class);
if (inMessage.getExchange().getOutFaultMessage() != null
&& inMessage.getExchange().getOutFaultMessage().getContent(Exception.class) != null) {
//check if there is an OutFaultMessage and Exception here first and return the Error fast
Exception ex = inMessage.getExchange().getOutFaultMessage().getContent(Exception.class);
if (ex instanceof org.apache.cxf.interceptor.Fault) {
org.apache.cxf.interceptor.Fault f = (org.apache.cxf.interceptor.Fault)ex;
if (!f.hasDetails()) {
xchng.setError(f);
}
} else {
xchng.setError(ex);
}
channel.send(xchng);
return;
}
StreamSource ss = new StreamSource(bais);
LOG.fine(new org.apache.cxf.common.i18n.Message("CREATE.NORMALIZED.MESSAGE", LOG).toString());
if (inMessage.getExchange().getOutFaultMessage() != null) {
Exception ex = inMessage.getContent(Exception.class);
if (ex instanceof org.apache.cxf.interceptor.Fault) {
org.apache.cxf.interceptor.Fault f = (org.apache.cxf.interceptor.Fault) inMessage.getContent(Exception.class);
if (!f.hasDetails()) {
xchng.setError(f);
}
} else {
xchng.setError(ex);
}
// As the fault is already marshalled by the fault handler
xchng.getFault().setBody(ss);
} else {
//copy attachments
if (outMessage != null && outMessage.getAttachments() != null) {
for (Attachment att : outMessage.getAttachments()) {
xchng.getOut().addAttachment(att.getId(), att
.getDataHandler());
}
}
//copy properties
for (Map.Entry<String, Object> ent : outMessage.entrySet()) {
//check if value is Serializable, and if value is Map or collection,
//just exclude it since the entry of it may not be Serializable as well
if (ent.getValue() instanceof Serializable
&& !(ent.getValue() instanceof Map)
&& !(ent.getValue() instanceof Collection)) {
xchng.getOut().setHeader(ent.getKey(), ent.getValue());
}
}
//copy securitySubject
xchng.getOut().setSecuritySubject((Subject) outMessage.get(NMRTransportFactory.NMR_SECURITY_SUBJECT));
xchng.getOut().setBody(ss);
}
LOG.fine(new org.apache.cxf.common.i18n.Message("POST.DISPATCH", LOG).toString());
channel.send(xchng);
}
} catch (Exception ex) {
LOG.log(Level.SEVERE, new org.apache.cxf.common.i18n.Message("ERROR.SEND.MESSAGE", LOG).toString(), ex);
}
}