in cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitOutputStream.java [98:146]
private void syncInvoke(org.apache.servicemix.nmr.api.Exchange xchng) throws Exception {
try {
if (!isOneWay) {
channel.sendSync(xchng);
Source content = null;
org.apache.servicemix.nmr.api.Message nm = null;
if (xchng.getFault(false) != null) {
content = xchng.getFault().getBody(Source.class);
nm = xchng.getFault();
} else {
content = xchng.getOut().getBody(Source.class);
nm = xchng.getOut();
}
Message inMessage = new MessageImpl();
message.getExchange().setInMessage(inMessage);
InputStream ins = NMRMessageHelper.convertMessageToInputStream(content);
if (ins == null) {
throw new IOException(new org.apache.cxf.common.i18n.Message("UNABLE.RETRIEVE.MESSAGE", LOG).toString());
}
inMessage.setContent(InputStream.class, ins);
//copy attachments
Collection<Attachment> cxfAttachmentList = new ArrayList<Attachment>();
for (Map.Entry<String, Object> ent : nm.getAttachments().entrySet()) {
cxfAttachmentList.add(new AttachmentImpl(ent.getKey(), (DataHandler) ent.getValue()));
}
inMessage.setAttachments(cxfAttachmentList);
//copy properties
for (Map.Entry<String, Object> ent : nm.getHeaders().entrySet()) {
if (!ent.getKey().equals(Message.REQUESTOR_ROLE)) {
inMessage.put(ent.getKey(), ent.getValue());
}
}
//copy securitySubject
inMessage.put(NMRTransportFactory.NMR_SECURITY_SUBJECT, nm.getSecuritySubject());
conduit.getMessageObserver().onMessage(inMessage);
xchng.setStatus(Status.Done);
channel.send(xchng);
} else {
channel.sendSync(xchng);
}
} finally {
channel.close();
}
}