我关注 Apache 骆驼休息服务(/sales),它在内部调用另一个休息服务(/getOrders)并获取对象列表。我能够在处理器中打印 JSON 响应,但在尝试从邮递员那里获取 java 对象作为响应。谁能帮我解决这个问题。附上响应日志以供参考。
@Component
public class ApplicationResource extends RouteBuilder {
@Autowired
private OrderService service;
@BeanInject
private OrderProcessor processor;
@Override
public void configure() throws Exception {
restConfiguration().component("servlet").port(9090).host("localhost");
rest().get("/getOrders").produces(MediaType.APPLICATION_JSON_VALUE).route().setBody(() -> service.getOrders());
rest().get("/sales").produces(MediaType.APPLICATION_JSON_VALUE).route()
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
.toD("http://localhost:9090/getOrders?bridgeEndpoint=true").convertBodyTo(String.class).marshal()
.json(JsonLibrary.Jackson, Order.class).to("log:foo?showHeaders=true");;
;
}
}