我正在使用 Apache Camel 将数据从 CSV 文件加载到 Web 服务。无论如何我可以显示请求和响应。下面是路由配置..
我从数组中拆分并聚合 100 个项目,以作为 POST 正文发送。
from(fileLocation)
.unmarshal().csv().bean(new CSVConverter(), "process")
.split(body())
.aggregate(constant(true), new GroupedBodyAggregationStrategy())
.completionSize(100)
.completionTimeout(1000)
.marshal().json(JsonLibrary.Jackson)
.setHeader("Authorization", simple(apiKEY))
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.setHeader(Exchange.HTTP_URI, simple(apiURL))
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
.to("https://serivceurl.com/abc");
请让我知道如何使用上述路线显示请求和响应?
您可以使用camel日志组件来记录标题;属性和身体
ex:
.to("log:DEBUG?showBody=true&showHeaders=true")
.to("https://serivceurl.com/abc");
.to("log:DEBUG?showBody=true&showHeaders=true")
更多选项请参考:https://camel.apache.org/log.html https://camel.apache.org/log.html
如果您计划使用 CXF 调用 Web 服务,则可以使用开箱即用的日志记录功能,如下所示:
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)