本文整理了Java中org.apache.camel.Message.copyFromWithNewBody()
方法的一些代码示例,展示了Message.copyFromWithNewBody()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.copyFromWithNewBody()
方法的具体详情如下:
包路径:org.apache.camel.Message
类名称:Message
方法名:copyFromWithNewBody
暂无
代码示例来源:origin: org.apache.camel/camel-spring-ws
@Override
public void doWithMessage(WebServiceMessage responseMessage) throws IOException, TransformerException {
SoapMessage soapMessage = (SoapMessage) responseMessage;
if (ExchangeHelper.isOutCapable(exchange)) {
exchange.getOut().copyFromWithNewBody(exchange.getIn(), soapMessage.getPayloadSource());
populateHeaderAndAttachmentsFromResponse(exchange.getOut(), soapMessage);
} else {
exchange.getIn().setBody(soapMessage.getPayloadSource());
populateHeaderAndAttachmentsFromResponse(exchange.getIn(), soapMessage);
}
}
});
代码示例来源:origin: io.syndesis.connector/connector-support-processor
@Override
public void process(Exchange exchange) throws Exception {
final Message message = exchange.getIn();
final Object body = message.getBody();
final ObjectNode rootNode = Json.copyObjectMapperConfiguration().createObjectNode();
if (!parameters.isEmpty()) {
final ObjectNode parametersNode = rootNode.putObject("parameters");
for (String parameter : parameters) {
parametersNode.put(parameter, message.getHeader(parameter, String.class));
}
}
if (body instanceof String) {
final String string = (String) body;
if (ObjectHelper.isNotEmpty(string)) {
rootNode.set("body", READER.readValue(string));
}
} else if (body instanceof InputStream) {
try (InputStream stream = (InputStream) body) {
if (stream.available() > 0) {
rootNode.set("body", READER.readValue(stream));
}
}
} else if (body != null) {
rootNode.putPOJO("body", body);
}
final String newBody = Json.toString(rootNode);
final Message replacement = new DefaultMessage(exchange.getContext());
replacement.copyFromWithNewBody(message, newBody);
ExchangeHelper.replaceMessage(exchange, replacement, false);
}
内容来源于网络,如有侵权,请联系作者删除!