带有自定义 http 标头的camel-cxfrs
我有一条定义 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过更多调查,发现这是 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)...