2016-09-23 156 views
0

我正在使用Apache Camel将数据从CSV文件加载到Web服务。无论如何,我可以显示请求和响应。以下是路由配置..Apache Camel HTTP显示请求和响应

我分割并聚合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"); 

请让我知道如何显示上述路线的请求和响应?

回答

0

您可以使用骆驼日志组件来记录标题;性能和身体

例如:

.to("log:DEBUG?showBody=true&showHeaders=true") 
.to("https://serivceurl.com/abc"); 
.to("log:DEBUG?showBody=true&showHeaders=true") 

更多选项PL参考:https://camel.apache.org/log.html

如果你打算使用CXF来调用Web服务,开箱记录功能,可以使用如下,

<cxf:bus> 
    <cxf:features> 
    <cxf:logging/> 
    </cxf:features> 
</cxf:bus>