spring restfull webservice post method

Thanks for your time.

I have written spring restfull webservice to handle the post method in my spring controller class, while i am testing with SOAP UI and RestClient i am getting "415 post method not available" message.

@RequestMapping(value = "/insertperfinfo)
public class SessionInfoController implements Controller {
   @RequestMapping(method = RequestMethod.GET) 
   public ModelAndView insertPerfinfoGet(HttpServletRequest request,Model model){
     String user=request.getParameter("user");
   }

   @RequestMapping(method = RequestMethod.POST) 
   public ModelAndView insertPerfinfoPOST(@RequestBody Perf perf,Model model) {
     // control not comes here .. when i give post request via REST client
   }

}

FYI : Working

  1.url is : http://server.port/webapp/insertperf?user=java&status=enable
  1.1.for GET method it is working fine as i expected .

Not working :
  2.i have created the Perf POJO in my web layer for query string parameter.
  2.2 passing the parameter via RESTClient with POST method.
  2.3 415 post method not available message

Any advise? thanks in advance.

Regards Vasanth D

Answers


Try changing the return type of your POST method to Perf. Also, annotate it with @ResponseBody. Finally, I see no need for the Model. So like this:

   @RequestMapping(method = RequestMethod.POST) 
   @ResponseBody
   public Perf insertPerfinfoPOST(@RequestBody Perf perf) {
     ...
   }

First off, there is a missing quote at the end of your annotation for the Class.

Also, try removing the RequestMapping annotation from the Class definition and modify the ReqeustMapping annotations of the methods:

@RequestMapping(method=RequestMethod.GET,value = "/insertperfinfo")

@RequestMapping(method=RequestMethod.POST,value = "/insertperfinfo")

Need Your Help

Make this Magento nested loop better

php magento foreach nested-loops

I am trying to get all stores on a Magento shop. By all stores, I mean all stores from all websites. I wrote this code and it works, but I'm a little concerned about the complexity of the nested fo...