use of org.apache.camel.component.cxf.util.ReaderInputStream in project camel by apache.
the class DefaultCxfBinding method getContentFromCxf.
protected static Object getContentFromCxf(Message message, DataFormat dataFormat, String encoding) {
Set<Class<?>> contentFormats = message.getContentFormats();
Object answer = null;
if (contentFormats != null) {
if (LOG.isTraceEnabled()) {
for (Class<?> contentFormat : contentFormats) {
LOG.trace("Content format={} value={}", contentFormat, message.getContent(contentFormat));
}
}
if (dataFormat == DataFormat.POJO) {
answer = message.getContent(List.class);
if (answer == null) {
answer = message.getContent(Object.class);
if (answer != null) {
answer = new MessageContentsList(answer);
}
}
} else if (dataFormat == DataFormat.PAYLOAD) {
List<SoapHeader> headers = CastUtils.cast((List<?>) message.get(Header.HEADER_LIST));
Map<String, String> nsMap = new HashMap<String, String>();
answer = new CxfPayload<SoapHeader>(headers, getPayloadBodyElements(message, nsMap), nsMap);
} else if (dataFormat.dealias() == DataFormat.RAW) {
answer = message.getContent(InputStream.class);
if (answer == null) {
answer = message.getContent(Reader.class);
if (answer != null) {
if (encoding == null) {
encoding = "UTF-8";
}
LOG.trace("file encoding is = {}", encoding);
answer = new ReaderInputStream((Reader) answer, Charset.forName(encoding));
}
}
} else if (dataFormat.dealias() == DataFormat.CXF_MESSAGE && message.getContent(List.class) != null) {
// CAMEL-6404 added check point of message content
// The message content of list could be null if there is a fault message is received
answer = message.getContent(List.class).get(0);
}
LOG.trace("Extracted body from CXF message = {}", answer);
}
return answer;
}
Aggregations