Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Unable to send the POST parameters value for REST Service

$
0
0
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温?砒뜩=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

Viewing all articles
Browse latest Browse all 5648

Trending Articles