[英]Can't use Apache Camel requestBody properly
我正在使用 Apcahe Camel 和 Spring boot,我的目標是使用 Camel 向 REST API 發出請求並獲得響應。
我有這個請求映射:
@RequestMapping("/annotation")
String getAnnotation(@RequestBody JSONObject payload) {
Object info = producerTemplate.requestBody("direct:annotation", payload, Object.class);
return info.toString();
}
還有這條路線;
from("direct:annotation").
convertBodyTo(String.class).
log("Receiving a annotation request").
to("http4://"+ address +"/annotation");
當我向 /annotation 提出請求時,我收到的響應是:
org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream@7d5a6dba
我想收到消息的正文,在這種情況下是 JSON。
嘗試擺脫 Object 類型,嘗試使用 String 代替。 您在 Object 上使用 info.toString() ,這就是您打印它的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.