带有自定义 http 标头的camel-cxfrs

发布于 2024-09-14 10:24:42 字数 843 浏览 4 评论 0原文

我有一条定义 CXFRS 端点的路由。我需要从入站请求中检索自定义 HTTP 标头值...

from(CXF_RS_ENDPOINT_URI)
      .process(new Processor() {
                public void process(Exchange exchange) throws Exception {
                        Message inMessage = exchange.getIn();    
                        System.out.println("headers->" + inMessage.getHeaders());
                        ...

这是我的单元测试代码来模拟客户端请求...

    HttpGet get = new HttpGet("http://localhost:9000/rest/customerservice/customers/126");
    get.addHeader("myHeader", "1234");
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = httpclient.execute(get);

问题是自定义标头“myHeader”在我的路由中不可用。还有其他方法可以到达吗?

通过查看camel-cxf源代码,我可以看到默认的标头策略/绑定逻辑仅设置预定义的HTTP标头。其他标头也没有通过是否有原因?

不管怎样,重写这种行为的最佳方法是什么?

谢谢

I have a route that defines a CXFRS endpoint. I need to retrieve custom HTTP header values from the inbound request...

from(CXF_RS_ENDPOINT_URI)
      .process(new Processor() {
                public void process(Exchange exchange) throws Exception {
                        Message inMessage = exchange.getIn();    
                        System.out.println("headers->" + inMessage.getHeaders());
                        ...

here is my unit test code to simulate a client request...

    HttpGet get = new HttpGet("http://localhost:9000/rest/customerservice/customers/126");
    get.addHeader("myHeader", "1234");
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = httpclient.execute(get);

The problem is that the custom header "myHeader" is unavailable from my route. Is there another way to get to it?

From looking at the camel-cxf source code, I can see that the default header strategy/binding logic only sets up predefined HTTP headers. Is there a reason why other headers aren't passed through as well?

Either way, what is the best approach to override this behavior?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傾旎 2024-09-21 10:24:42

经过更多调查,发现这是 CAMEL-CXF 中的一个错误。它已被修复以支持 Camel trunk 中的自定义标头(预计在 2.5 版本中发布)...

After more investigating, this was found to be a bug in CAMEL-CXF. It has been fixed to support custom headers in the Camel trunk (slated for 2.5 release)...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文