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

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

问题描述

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

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

例如:

.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

如果您打算使用 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天全站免登陆