Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top