Announcement Announcement Module
Collapse
No announcement yet.
Is there any sample for using the RESTFUL API? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is there any sample for using the RESTFUL API?

    hi, all

    Can I get the result from Spring Roo project via restful api? My client side is php based...

    For example, the rest url is:
    http://localhost:8080/WebSystem/userinfos

    how can I get the userinfo(name, password, email) list in php client? Also, how can I get the userinfo list in java rest client?

    New to REST and any help is highly appreciated!!

  • #2
    Check this presentation

    http://2010.geecon.org/materials/pre...con-tzolov.pdf

    Comment


    • #3
      thanks for your help. i found there are restful api in the .aj file which are automatically generated. and now i can do the post/get/delete operations via restful api, but the PUT seems can not work. I checked the .aj file, seems actually no api for the PUT operation, is this right?

      while from the tutorial at: http://static.springsource.org/sprin...beginning.html

      if I do PUT at http://localhost:8080/WebSystem/userinfos/3, it should can modify the userinfo which has id=3...

      How can I do the PUT operation in spring roo? the only method I found in the .aj file are something like below, and obviously it is not the restful api for PUT operation:
      ---------------
      @RequestMapping(method = RequestMethod.PUT)
      public String UserInfoController.update(@Valid UserInfo userInfo, BindingResult result, Model model) {
      if (result.hasErrors()) {
      model.addAttribute("userInfo", userInfo);
      return "userinfoes/update";
      }
      userInfo.merge();
      return "redirect:/userinfoes/" + userInfo.getId();
      }
      ---------------

      Any one could help? Thanks so much again.

      Comment


      • #4
        Your client's "update user info" HTTP request needs to:
        • use the HTTP "PUT" method (which is not natively supported by HTML forms, but is by many other web clients*)
        • go to the correct URL, e.g. http://hostname/pizza/userinfo/3
        • contain a parameter for each domain field being updated (as for a POST request, which you already have working)
        * Also note that since 3.0, Spring MVC's HiddenHttpMethodFilter allows web clients to simulate a PUT request by sending a POST request that contains a "_method" parameter with a value of "PUT". See "HTTP Method Conversion" in this blog post for details:

        http://blog.springsource.com/2009/03...-spring-3-mvc/

        Comment


        • #5
          Spring RESTful service example

          Check out http://soaprobe.blogspot.co.uk/2012/...ple-guide.html

          Robert

          Originally posted by xeoshow View Post
          hi, all

          Can I get the result from Spring Roo project via restful api? My client side is php based...

          For example, the rest url is:
          http://localhost:8080/WebSystem/userinfos

          how can I get the userinfo(name, password, email) list in php client? Also, how can I get the userinfo list in java rest client?

          New to REST and any help is highly appreciated!!

          Comment

          Working...
          X