You need to map the post Body into the message header, as the SimpleConsumer[1] just put the request body into the message body.
[1]https://camel.apache.org/cxfrs#CXFRS-ConsumingaRESTRequest-SimpleBindingStyle -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese) Twitter: willemjiang Weibo: 姜宁willem On October 20, 2014 at 12:43:06 AM, sayed_india ([email protected]) wrote: > Hello, > Following the sample code below works perfectly fine for REST GET method, > But the POST method always inserts the null record, > > > > Can any one please suggest me in case of any change required. > > Route Builder: > > public void configure() throws Exception { > > from("cxfrs:http://0.0.0.0:9090?resourceClasses=cc.notsoclever.examples.CompanyService&bindingStyle=SimpleConsumer") > > .choice() > .when(header("operationName").isEqualTo("getCompany")) > .to("sql:SELECT * from company where id = :#id") > .when(header("operationName").isEqualTo("createCompany")) > .to("sql:INSERT INTO company(name, symbol) VALUES > (:#name, :#symbol)") > .when(header("operationName").isEqualTo("getCompanies")) > .to("sql:select * from company") > .when(header("operationName").isEqualTo("updateCompany")) > .to("sql:UPDATE company SET name = :#name, symbol = > :#symbol where id = :#id") > .when(header("operationName").isEqualTo("deleteCompany")) > .to("sql:DELETE FROM company where id = :#id") > .end() > .marshal().json(JsonLibrary.Jackson);//uncomment for JSON > ------------- > Service: > > --------- > @Path("/") > public interface CompanyService { > > @GET > @Path("company/{id}") > public String getCompany(@PathParam("id") String id); > > @Produces(MediaType.APPLICATION_XML) > @GET > @Path("company") > public String getCompanies(); > > @PUT > @Path("company/{id}") > public String updateCompany(@PathParam("id") String id); > @DELETE > @Path("company/{id}") > public String deleteCompany(@PathParam("id") String id); > //@Consumes("application/json") > @Consumes(MediaType.APPLICATION_JSON) > @POST > @Path("company") > //public String createCompany(String data); > public String createCompany(@PathParam("name") String > name,@PathParam("symbol") String symbol); > > > } > Note:ID is auto generated. > > Request an early response. > > Thanks, > Sayed > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Unable-to-send-the-POST-parameters-value-for-REST-Service-tp5757760.html > > Sent from the Camel - Users mailing list archive at Nabble.com. >
