I would like to build my own RESTful API Server and I have no idea what I need for that.
I'll tell you a bit about the project:
On a Webservice (www.mysite.com/) users can register and manage their account and so on. But they also can use the RESTful API (mysite.com/api/...) and can do there pretty much the same via REST.
What is a good way to realize that? Do I need to use jetty or something similar? Should I split web service and restful api ? what I a good architecture for that?
Thanks :)
All client-server operations should be stateless, and any state management that is required should take place on the client, not the server. RESTful resource caching. All resources should allow caching unless explicitly indicated that caching is not possible. Layered system.
You can use Spring controller for building a restful server. You can run it on tomcat or jetty doesn't matter.
Check this url : http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html
Tomcat and Jersey are easy to get up and running. I've had some issues with Tomcat 7 and Jersey, but with Tomcat 6 it was straight forward.
This tutorial is quite easy to follow. It's a bit old, but the principle remains the same.
IBM provides good set of information and tutorials about building RESTful web service with Java (Link). After getting your web service running, you can deploy it to Amazon. Take a look at AWS Elastic Beanstalk.
In 2017 one of the best solutions would be to use spring boot. Gives you great effects without writing tons of code.
@RestController
public class HelloController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}
I found a simple example at http://coder2design.com/rest-web-services/ to build a REST application.
All other configurations are nicely explained.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With