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.

Reply via email to