camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robinhowlett <ro...@silverchalice.com>
Subject CXF-RS, @QueryParam and @HeaderParam
Date Wed, 13 Apr 2011 22:55:45 GMT
In my context.xml I have defined a jaxrs:server with serviceBean referenced,
and both a cxf:rsServer and cxf:rsClient. 


    	
    		
    	
    
    
    
    
    
    
    
    
    
    
    	
    

My route is defined in RestTestRouteBuilder using Java DSL and is just:

from("cxfrs://bean://rsServer").to("cxfrs://bean//rsClient");

My test case is using the producerTemplate to send to the cxfrs endpoint
defined by the cxf:rsServer and I include query parameters. A Processor sets
the ExchangePattern as InOut, and the inMessage has a HTTP_METHOD header set
to "GET" and a Response Class header to InputStream

Exchange exchange =
template.send("cxfrs://http://localhost:9000/route/test/query?httpClientAPI=true&id=12&orgId=34",
new Processor() {        
                public void process(Exchange exchange) throws Exception {
                    exchange.setPattern(ExchangePattern.InOut);
                    Message inMessage = exchange.getIn();
                    inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
                   
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS,
InputStream.class);
                    inMessage.setBody(null); 
        }
            
});
     
String response = exchange.getOut().getBody(String.class);
assertNotNull("The response should not be null ", response);
assertEquals("The response value is incorrect", "test", response);

My CXF service bean has paths set correctly and my "query" method is
expecting two @QueryParams

@Path("/test")
public class QueryService {
...
        @GET
	@Path("/query")
	public Response getSomething(@QueryParam("id") String id,
@QueryParam("orgId") String orgId) {
		System.out.println(id);
		System.out.println(orgId);
		return "test";
	}
...
}

However when I run the test, the QueryParams are receving nothing (null);
after many tries, I realized that the parameters that were set on the URL
are actually coming in as of type @HeaderParam
...
        @GET
	@Path("/query")
	public Response getSomething(@HeaderParam("id") String id,
@HeaderParam("orgId") String orgId) {
		System.out.println(id);
		System.out.println(orgId);
		return "test";
	}
...

What's happening to convert those to type @HeaderParam and how can I get
them as of type @QueryParam?

--
View this message in context: http://camel.465427.n5.nabble.com/CXF-RS-QueryParam-and-HeaderParam-tp4301808p4301808.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message