Curs 8 - RESTful Web Services

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Proiectarea aplicatiilor J2EE

Curs 8 - RESTful Web Services

Serviciile RESTful

Representational state transfer este arhitectura specifica World Wide Web,


comunicand tipic peste HTTP
Sistemele ce respecta specificatiile REST sunt numite RESTful
Caracteristici:

Simplitate: delimiteaza strict componentele client si server


Stateless: intre requests nu sunt pastrate date pe sesiune
Performanta si scalabilitate
Portabilitate prin respectarea standardului REST, peste HTTP

RESTful Web Services

Servicii Web RESTful implementate in scopul extinderii functionalitatii


serverului
Asculta cererile HTTP ale clientilor, raspunzand in diverse formate (HTML,
XML, JSON, text etc.)
Publica resurse utilizand URI, pentru care permite operatiuni tip CRUD

JAX-RX

Standardul J2EE a RESTful Web Services


Jersey - implementarea Oracle (Sun) a JAX-RX
JAX-RS utilizeaza Java annotations pentru a marca elemente specifice
serviciilor web, usurand dezvoltarea aplicatiilor

JAX-RS Annotations
Documentation: https://jersey.java.net/documentation/latest/jaxrs-resources.html

@Path("/calc")
public class CalcREST {

@GET
@Path("/add/{a}/{b}")
@Produces(MediaType.TEXT_PLAIN)
public String addPlainText(@PathParam("a") double a, @PathParam("b") double b) {

@POST
@Consumes("application/json")
@Produces("application/json")
public RestResponse<Contact> create(Contact contact) {

@PUT
@Consumes("application/json")
@Produces("application/json")
@Path("{contactId}")
public RestResponse<Contact> update(Contact contact) {

Practice

Configure Eclipse Maven plugin, Tomcat runtime


http://tutorial-academy.com/restful-webservice-jersey-maven/

You might also like