JavaOne 2008 - JAX-RS: The Java API for RESTful Web Services
May 6, 2008 11:35 pm JavaI attended the session “JAX-RS: The Java API for RESTful Web Services” presented by Marc Hadley and Paul Sandoz of SUN Microsystems. This session gave a brief overview of what RESTful web services are, and how they can be used with the JAX-RS API.
There are five steps of REST:
- Give everything an ID — this translates to a URI reference
- Link things together — using an XML definition
- Use standard methods — GET, POST, PUT, DELETE
- Multi-representations of data — XML, XHTML, JSON, Text
- Stateless communication — everything needed to make a request is contained in the request
Using REST vs SOAP has many benefits. On the server, there is horizontal scaling, simple fail over, cacheing, and reduced coupling. On the client, there is easy experimentation in the browser, bookmarking, broad language support, and a choice of data formats.
SUN’s Jersey reference implementation of the JAX-RS API uses annotations for defining RESTful web services. The @Path notation is used for defining ID’s. A link is defined with the @Context notation. The standard methods use @GET, @PUT, @POST, and @DELETE annotations. Multiple representations of the data are done using the @ProduceMime and @ConsumeMime notations
