You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vikson <vi...@cognizant.com> on 2017/02/09 06:45:51 UTC
Re: Not seeing query params on REST DSL
Hi Steve,
Were you able to find a solution for your query. I'm facing the exact same
issue; not able to read query params from the URL in case of the RESTLET
component. I was earlier using the SERVLET component and I was able to read
the query params as well as the header values from the incoming request. I
would like to achieve the same using the RESTLET component.
Code fragment for reference:
//Rest services exposed
rest("/").description("XYZ
service").consumes(MediaType.APPLICATION_JSON_VALUE).produces(MediaType.APPLICATION_JSON_VALUE)
.get("/process?arg1={arg1}&arg2={arg2}")
.consumes(MediaType.APPLICATION_JSON_VALUE)
.to("bean:testServiceImpl?method=callTestService(${header.arg1},${header.arg2},${header.hdrId})").produces(MediaType.APPLICATION_JSON_VALUE);
// hdrId is the header I'm trying to read & this was working with the
SERVLET component, all request params, header values are read.
Any help would be appreciated. Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/Not-seeing-query-params-on-REST-DSL-tp5781442p5793707.html
Sent from the Camel - Users mailing list archive at Nabble.com.
RE: Not seeing query params on REST DSL
Posted by Steve Huston <sh...@riverace.com>.
I apologize for the delay responding to this.
I was able to get this working but parsing out the URI info separately, like the below. It's from a test program so it has some assumptions about what it should be getting.
-Steve
---------------------------
String httpRequest = resultEndpoint.getExchanges().get(0).getIn().getHeader("CamelRestletRequest", String.class);
// httpRequest should say PUT http://.... HTTP/1.1 - split it to get the URL
String[] pieces = httpRequest.split("\\s+");
URL url = new URL(pieces[1]);
String req[] = url.getQuery().split("=");
assertEquals("id query param is present", "id", req[0]);
assertEquals("id query value mismatch", "5678", req[1]);
> -----Original Message-----
> From: vikson [mailto:vikram.sonawane2@cognizant.com]
> Sent: Thursday, February 09, 2017 1:46 AM
> To: users@camel.apache.org
> Subject: Re: Not seeing query params on REST DSL
>
> Hi Steve,
>
> Were you able to find a solution for your query. I'm facing the exact same
> issue; not able to read query params from the URL in case of the RESTLET
> component. I was earlier using the SERVLET component and I was able to
> read the query params as well as the header values from the incoming
> request. I would like to achieve the same using the RESTLET component.
>
> Code fragment for reference:
>
> //Rest services exposed
> rest("/").description("XYZ
> service").consumes(MediaType.APPLICATION_JSON_VALUE).produces(Med
> iaType.APPLICATION_JSON_VALUE)
> .get("/process?arg1={arg1}&arg2={arg2}")
> .consumes(MediaType.APPLICATION_JSON_VALUE)
>
> .to("bean:testServiceImpl?method=callTestService(${header.arg1},${header
> .arg2},${header.hdrId})").produces(MediaType.APPLICATION_JSON_VALUE)
> ;
> // hdrId is the header I'm trying to read & this was working with the SERVLET
> component, all request params, header values are read.
>
> Any help would be appreciated. Thanks.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Not-
> seeing-query-params-on-REST-DSL-tp5781442p5793707.html
> Sent from the Camel - Users mailing list archive at Nabble.com.