Curs 8 - RESTful Web Services

4
Proiectarea aplicatiilor J2EE Curs 8 - RESTful Web Services

Transcript of Curs 8 - RESTful Web Services

Page 1: Curs 8 - RESTful Web Services

7/24/2019 Curs 8 - RESTful Web Services

http://slidepdf.com/reader/full/curs-8-restful-web-services 1/6

Proiectarea aplicatiilor J2EE

Curs 8 - RESTful Web Services

Page 2: Curs 8 - RESTful Web Services

7/24/2019 Curs 8 - RESTful Web Services

http://slidepdf.com/reader/full/curs-8-restful-web-services 2/6

Serviciile RESTful

● Representational state transfer  este arhitectura specifica Wor

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

Page 3: Curs 8 - RESTful Web Services

7/24/2019 Curs 8 - RESTful Web Services

http://slidepdf.com/reader/full/curs-8-restful-web-services 3/6

RESTful Web Services

● Servicii Web RESTful implementate in scopul extinderii function

serverului

● Asculta cererile HTTP ale clientilor, raspunzand in diverse forma

XML, JSON, text… etc.)

● Publica resurse utilizand URI, pentru care permite operatiuni tip

Page 4: Curs 8 - RESTful Web Services

7/24/2019 Curs 8 - RESTful Web Services

http://slidepdf.com/reader/full/curs-8-restful-web-services 4/6

JAX-RX

● Standardul J2EE a RESTful Web Services

● Jersey - implementarea Oracle (Sun) a JAX-RX

● JAX-RS utilizeaza Java annotations pentru a marca elemente sp

serviciilor web, usurand dezvoltarea aplicatiilor 

Page 5: Curs 8 - RESTful Web Services

7/24/2019 Curs 8 - RESTful Web Services

http://slidepdf.com/reader/full/curs-8-restful-web-services 5/6

JAX-RS AnnotationsDocumentation: 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) {

Page 6: Curs 8 - RESTful Web Services

7/24/2019 Curs 8 - RESTful Web Services

http://slidepdf.com/reader/full/curs-8-restful-web-services 6/6

Practice

● Configure Eclipse Maven plugin, Tomcat runtime

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