Ok, I see what's happening here.
The SimpleConsumer binding style is truly injecting the parameters into
Camel IN message headers with names: q, start, size. If you add a "log all"
endpoint just after the CXFRS consumer, you will see the parameters sitting
there as message headers: .to("log:TEST?showAll=true");
However, your implementation bean (searchRestServiceImpl) does not instruct
Camel how to fill in the values for the method arguments. You should add
@Header annotations to your method signature; then Camel will know to
inject the header values adequately. More info on Bean Binding here: [1] &
[2].
Alternatively you can use the camel-cxfbean component [3] to open up a
Jetty server and proxy all invocations to your CXF RS bean.
P.S.: The SimpleConsumer binding style gives the *false* appearance that it
only maps ONE parameter in this case because you have no HTTP
entity/payload in this request (like you would in a POST or PUT, maybe).
Therefore, it has to set _something_ as the IN Body, and it selects the
first argument of the JAX-RS method for convenience. But the rest of the
parameters are injected in the headers, as the docs [4] specify.
[1] http://camel.apache.org/bean-binding.html
[2] http://camel.apache.org/parameter-binding-annotations.html
[3] http://camel.apache.org/cxf-bean-component.html
[4]
http://camel.apache.org/cxfrs.html#CXFRS-ConsumingaRESTRequestSimpleBindingStyle
HTH,
*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk
On Fri, Nov 1, 2013 at 2:53 AM, arunodhaya80 <[email protected]> wrote:
> Hi, I am referring to the following link (specially the Simple Binding
> style)
> http://camel.apache.org/cxfrs.html
>
> What I am trying to do is basic - pass three query parameters and receive
> them in the REST implementation class. For some reason, the second and the
> subsequent Query Parameters are just null. The first one works perfectly
> fine. I am using Camel+JAX-RS (CXF). This is just a GET request. The URL I
> am using is
>
> `
> http://localhost:8181/cxf/coreservices/search?q=health&start=100&size=924`
>
> I guess this information is not useful - I am running this on top of Karaf.
>
> **Here is my Interface declaration**
>
> @Path("search")
> public interface SearchRestService {
>
>
> @GET
> @Produces(MediaType.APPLICATION_JSON)
> public String searchGet(@QueryParam ("q") String q, @DefaultValue("0")
> @QueryParam("start") String start, @DefaultValue("10") @QueryParam("size")
> String size );
>
>
>
> **Implementation**
>
>
> public SearchResult<WikiSearchHit> searchGet(String q, String start,
> String size){
>
> logger.info("Inside wiki GET method: " +q + " start:"+start + "
> size:"+ size);
>
>
> The `q` parameter comes in fine as `health` but the start and the size
> parameters are just null. Surprisingly, the default values aren't getting
> picked up too.
>
> I am afraid I am doing something wrong in my camel routing.
>
> **Router**
>
> @Override
> public void configure() throws Exception {
>
> from("cxfrs://bean://rsServer?bindingStyle=SimpleConsumer")
> .multicast()
> .parallelProcessing()
> .aggregationStrategy(new CoreSearchResponseAggregator())
> .beanRef("searchRestServiceImpl", "searchGet")
> ...
>
> The relevant blueprint declarations are :
>
> <cxf:bus id="coreServicesBus">
> </cxf:bus>
>
> <jaxrs:server address="/coreservices" id="rsServer">
> <jaxrs:serviceBeans>
> <ref component-id="searchRestServiceImpl" />
> </jaxrs:serviceBeans>
> </jaxrs:server>
>
>
> I am pretty sure I am doing something really stupid. I'll be really
> grateful for any clues on what I am doing wrong.
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/JAX-RS-and-Camel-Except-1st-QueryParameter-all-others-are-null-tp5742470.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>