开发者

camel-cxfrs with custom http headers

开发者 https://www.devze.com 2023-01-11 06:27 出处:网络
I have a route that defines a CXFRS endpoint.I need to retrieve custom HTTP header values from the inbound request...

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 passe开发者_StackOverflowd through as well?

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

thanks


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)...

0

精彩评论

暂无评论...
验证码 换一张
取 消