Thanks Raul for your help
Cheers, Sergey
On 01/11/13 17:18, Raul Kripalani wrote:
Hey Sergey,
I'll take a look.
Thanks for providing a workaround to the user so quickly! ;-)
Regards,
*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 4:00 PM, Sergey Beryozkin <[email protected]>wrote:
Hi, thanks for making it work;
You might want to reuse (CXF) JAXRSUtils.**getStructuredParams(query,
"&"),
this will return JAX-RS MultivaluedMap which will hold list values, and
will take care of parameters having multiple values (&a=1&a=2, etc).
I'm still not sure how it can be resolved with Simple Binding Style, but I
think I can manage to do a patch, unless Raul (Simple Binding Style guru)
can beat me to it :-)
Cheers. Sergey
On 01/11/13 14:28, arunodhaya80 wrote:
Thanks a lot for helping out and the heads-up.
Yes, you are right. I could get the query portion alone using:
String query = exchange.getIn().getHeader(**Exchange.HTTP_QUERY,
String.class);
Taking up from your hint, I am doing the following and my flow looks
complete :
***Interface ***
@GET
@Path("search")
@Produces(MediaType.**APPLICATION_JSON)
public String searchGet();
***Implementation - Target method***
public SearchResult<WikiSearchHit> wikiGet(Exchange exchange){
String q = exchange.getIn().getHeader("q"**, String.class);
String size = exchange.getIn().getHeader("**size",
String.class);
String start = exchange.getIn().getHeader("**start",
String.class);
***Router***
public class RestToBeanRouter extends RouteBuilder {
@Override
public void configure() throws Exception {
from("cxfrs://bean://rsServer?**bindingStyle=SimpleConsumer")
.process(new ParameterProcessor())
.removeHeaders("CamelHttp*")
.multicast()
.parallelProcessing()
.aggregationStrategy(new CoreSearchResponseAggregator()*
*)
.beanRef("**searchRestServiceImpl", "wikiGet")
....
.end()
.marshal().json(JsonLibrary.**Jackson);
//.to("log://camelLogger?**level=TRACE");
}
class ParameterProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Map<String, String> stringStringMap =
convertQueryStringAsMap(**exchange.getIn().getHeader(**
Exchange.HTTP_QUERY,
String.class));
//System.out.println("**stringStringMap = " +
stringStringMap);
for (Map.Entry<String, String> eachParamEntry :
stringStringMap.entrySet()) {
exchange.getIn().setHeader(**eachParamEntry.getKey(),
eachParamEntry.getValue());
}
}
private Map<String,String> convertQueryStringAsMap(String
queryString){
return
Splitter.on("&").**omitEmptyStrings().**trimResults().**
withKeyValueSeparator("=").**split(queryString);
}
}
}
Thanks a ton !!!
--
View this message in context: http://camel.465427.n5.nabble.**
com/JAX-RS-and-Camel-Except-**1st-QueryParameter-all-others-**
are-null-tp5742470p5742502.**html<http://camel.465427.n5.nabble.com/JAX-RS-and-Camel-Except-1st-QueryParameter-all-others-are-null-tp5742470p5742502.html>
Sent from the Camel - Users mailing list archive at Nabble.com.