You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Matt Narrell <ma...@gmail.com> on 2011/12/27 15:52:17 UTC

Camel CXFRS and multiple @QueryParam arguments

Hello all,

Suppose I have a method to expose via REST:

	@GET
	@Path("/doSomething")
	public Response doSomething(@QueryParam("foo") String foo, @QueryParam("bar") String bar) {..}

Then wired in Spring XML as:

	<camelCxf:rsServer id="someBean" address="/somePath" serviceClass="org.some.package.SomeService"/>

Then added to a route as:

	from("cxfrs:bean:someBean").process(..)

===========================================

When I reach the processor, the exchange body is a MessageContentsList containing the values passed for "foo" and "bar".  Is there a way to retrieve these query params via their annotated names, either by some TypeConverter or header property?  I'm not guaranteed that the callers will pass these parameters ordered as they are in the method signature, so iterating over the MessageContentsList is tricky if the params are of the same type, or if not all the parameters were provided.  

Alternatively, I could inspect the CamelHttpQuery header in my processor and construct a Map, but I'm curious if there's configuration, TypeConverters, or other ways to achieve this, out-of-the-box.

Thanks,
Matt

Re: Camel CXFRS and multiple @QueryParam arguments

Posted by Willem Jiang <wi...@gmail.com>.
Hi Matt,

The MessageContentsList is use the same parameter order as the method 
argument, I think you can count on it.
You can inspect the CamelHttpQuery header at the same time to verify my 
suggestion,
 I don't think camel-cxfrs support the passer it as Map out of the box.

On Tue Dec 27 22:52:17 2011, Matt Narrell wrote:
> Hello all,
>
> Suppose I have a method to expose via REST:
>
> 	@GET
> 	@Path("/doSomething")
> 	public Response doSomething(@QueryParam("foo") String foo, @QueryParam("bar") String bar) {..}
>
> Then wired in Spring XML as:
>
> 	<camelCxf:rsServer id="someBean" address="/somePath" serviceClass="org.some.package.SomeService"/>
>
> Then added to a route as:
>
> 	from("cxfrs:bean:someBean").process(..)
>
> ===========================================
>
> When I reach the processor, the exchange body is a MessageContentsList containing the values passed for "foo" and "bar".  Is there a way to retrieve these query params via their annotated names, either by some TypeConverter or header property?  I'm not guaranteed that the callers will pass these parameters ordered as they are in the method signature, so iterating over the MessageContentsList is tricky if the params are of the same type, or if not all the parameters were provided.
>
> Alternatively, I could inspect the CamelHttpQuery header in my processor and construct a Map, but I'm curious if there's configuration, TypeConverters, or other ways to achieve this, out-of-the-box.
>
> Thanks,
> Matt



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang