Announcement Announcement Module
No announcement yet.
Web Service POST did not work Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web Service POST did not work

    I am using Roo 1.1.3.
    I have two web services, one is GET and the other one is POST in the controller below.

    The GET works fine, but POST doesn't. The error is "Content type 'text/plain;charset=UTF-8' not supported". What could be the reason ?

    public class WSController {

    @RequestMapping(value = "/offers", method = RequestMethod.GET, headers = "Accept=application/xml")
    public @ResponseBody OfferList findOffersByStoresXml(@RequestParam("store_id") Long store_id) {
    Set<Store> stores = new HashSet<Store>();
    List<Offer> offers = Offer.findOffersByStores(stores).getResultList();
    OfferList list = new OfferList(offers);
    return list;

    @RequestMapping(value = "/saverating", method = RequestMethod.POST, headers = "Accept=application/xml")
    public @ResponseBody RatingInfo saveOfferRating(@RequestBody RatingInfo rating, BindingResult bindingResult) {
    if (!bindingResult.hasErrors()) {
    OfferRating offerRating = new OfferRating();
    offerRating.setOffer(Offer.findOffer(new Long(rating.getCouponid())));

    return rating;
    }else {
    return null;

    Content type 'text/plain;charset=UTF-8' not supported ndlerMethodInvoker.readWithMessageConverters(Handl ndlerMethodInvoker.resolveRequestBody(HandlerMetho ndlerMethodInvoker.resolveHandlerArguments(Handler ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho
    org.springframework.web.servlet.DispatcherServlet. doDispatch(

  • #2
    REST Support

    Tested with following code. @RequestBody does return the posted xml. I guess now the question should be:

    Is "REST Support" still available in the spring 3.0.x and above as indicated in 3.0.0.M3 ?

    It is removed in the latest Spring document.

    @RequestMapping(value = "/saverating", method = RequestMethod.POST, headers = "Accept=application/xml")
    public @ResponseBody RatingInfo saveOfferRating(@RequestBody String rating) {

    return null;


    • #3
      I think you are in the wrong forum - this is for Spring Roo specific questions.

      From a brief look at your example, you are defining your REST controller methods to only accept XML: 'Accept=application/xml', yet your request shows you are sending 'text/plain'. This means that the controller methods will not be deemed as applicable by the HandlerMethodInvoker.