Apache Camel HTTP显示请求和响应 [英] Apache Camel HTTP display request and response

查看:2792
本文介绍了Apache Camel HTTP显示请求和响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using Apache Camel to load data from CSV file to a webservice. Is there anyway I can display request and response. Below is the route configuration..

我从数组中拆分并聚合100个项目作为POST正文发送。

I split and aggregate 100 items from array to be sent as POST body.

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");

请告诉我如何以上述路线显示请求和回复?

Please let me know how can I display request and response with above route?

推荐答案

您可以使用驼峰日志组件来记录标题;属性和正文

You can use camel log component to log headers; properties and body

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

For more options pl refer: https://camel.apache.org/log.html

如果您打算使用CXF来调用Web服务,可以使用开箱即用的日志记录功能,如下所示,

If you are planning to use CXF to invoke web service, out of the box logging feature can be used as below,

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

这篇关于Apache Camel HTTP显示请求和响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆