github链接:https://github.com/shahulsley/came-rest-dsl
我已经使用 Apache Camel REST DSL 在 Spring Boot 中编写了 REST API。除了 createBatch 之外,所有端点都工作正常,
输入正文: [{ "发货人编号": "AAA111", "handOffDate": "2024-08-05T11:40:15.123456", “开始日期”:“2024-09-01T02:36:15.678543” }, { "发货人编号": "BBB222", "开始日期": "2024-08-06T14:30:00.654321", “结束日期”:“2024-09-10T04:15:00.987654” } ]
期望:接收List并一一检索并调用创建单个端点。如果您有任何建议请告诉我
尝试将其转换为列表,但失败了
问题是接收 Json 作为列表。所以,我们需要告诉Camel,传入的数据是DTO的List, 贝娄解决了问题!
restConfiguration()
.component("servlet")
.bindingMode(RestBindingMode.off); //Changed it to "off" from "json", manually unmarshal and marshal
JacksonDataFormat requestDataFormat = new JacksonDataFormat(SpecialLaunchDTO.class);
requestDataFormat.useList();
from("direct:createBatch")
.unmarshal(requestDataFormat)
.bean(specialLaunchService, "createShipperBatch(${body})")
.marshal().json(JsonLibrary.Jackson);