Results 1 to 5 of 5

Thread: Is there any sample for using the RESTFUL API?

  1. #1

    Default 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. #2
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    16

  3. #3

    Default

    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.

  4. #4
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    667

    Lightbulb

    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/
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  5. #5

    Default Spring RESTful service example

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

    Robert

    Quote 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!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •