Académique Documents
Professionnel Documents
Culture Documents
SERVICES
Exposé – Informatique & Réseaux
CHAMBON Florian
14 janvier 2014
1
Introduction
Présentation de Rest
Serveur Java JAX-RS
Démonstration
2
Exposé - Informatique & Réseaux
Introduction
Présentation de Rest
Serveur Java JAX-RS
Démonstration
3
Exposé - Informatique & Réseaux
WEB SERVICES
Un service est un travail réalisé par un fournisseur pour le compte
d’un consommateur
4
Exposé - Informatique & Réseaux
WEB SERVICES - TECHNOLOGIES
5
Exposé - Informatique & Réseaux
Introduction
Présentation de Rest
Serveur Java JAX-RS
Démonstration
6
Exposé - Informatique & Réseaux
REPRESENTATIONNAL STATE TRANSFER
Créé pour interagir avec les systèmes distribués
Architecture orienté ressources
Créé en 2000 par Roy Fielding - Thèse de doctorat
Projet Waka
Principal auteur de la spécification HTTP
Membre fondateur de la fondation Apache
Développeur du serveur Web Apache
7
Exposé - Informatique & Réseaux
REPRESENTATIONNAL STATE TRANSFER
8
Exposé - Informatique & Réseaux
REPRESENTATIONNAL STATE TRANSFER
9
Exposé - Informatique & Réseaux
CONTRAINTES
10
Exposé - Informatique & Réseaux
ARCHITECTURE
11
Exposé - Informatique & Réseaux
REST - PRINCIPE CLÉS
12
Exposé - Informatique & Réseaux
UNE RESSOURCE DISTRIBUÉE
13
Exposé - Informatique & Réseaux
URL : IDENTIFIANT DE LA RESSOURCE
14
Exposé - Informatique & Réseaux
HTTP – IDENTIFIANT DES OPÉRATIONS
GET
Usage : Read – Lecture d’une ressource / d’une collection
200 OK – 404 NOT FOUND
PUT
Usage : Update – Mise à jour d’une ressource
201 CREATED – 204 NO CONTENT
DELETE
Usage : Delete – Supression d’une ressource
200 OK – 404 NOT FOUND – 304 NOT MODIFIED
POST
Usage – Create – Création d’une ressource
200 OK – 404 NOT FOUND
15
Exposé - Informatique & Réseaux
EXEMPLE - LIBRARY
URL Méthode Action
17
Exposé - Informatique & Réseaux
JSON ET XML
{
Isbn : 2070541274, <Book>
<Isbn>2070541274</isbn>
author : JK rowling, <author>JK Rowling</author>
title : Harry potter n° X, <title> Harry Potter .. </title>
<style> Fantasy </style>
style : Fantasy </Book>
}
18
Exposé - Informatique & Réseaux
QUI L’UTILISE ?
19
Exposé - Informatique & Réseaux
AVANTAGES DE REST
20
Exposé - Informatique & Réseaux
INCONVÉNIENTS/LIMITATIONS DE REST
21
Exposé - Informatique & Réseaux
Introduction
Présentation de Rest
Serveur Java JAX-RS
Démonstration
22
Exposé - Informatique & Réseaux
REST & JAVA - SPÉCIFICATION JAX-RS
23
Exposé - Informatique & Réseaux
SPÉCIFICATION JAS-RX
24
Exposé - Informatique & Réseaux
JAX-RS : ARCHITECTURE
25
Exposé - Informatique & Réseaux
HELLO WORLD
@Path("/helloworld")
Ø Définition d’un chemin
public class HelloWorldRestful { pour associer la
@GET ressource hello a une
URL
@Produce(MediaType.Html)
public String getHelloWorld(){
Ø Lecture de la ressource
// Code source associé HelloWorld via une
Return « Hello World »; requete HTTP de type
} GET
26
Exposé - Informatique & Réseaux
FIL ROUGE : GESTION D’UNE
BIBLIOTHÈQUE
28
Exposé - Informatique & Réseaux
@PATH
L’annotation @Path peut également annoter des méthodes de la
classe
L’URL est la concaténation du @Path de la classe et du @Path de la
méthode
Exemple : Je veux tous les livre d’un auteur précis
@Path(«/book/author-{author} »)
@GET
@Path(« author/{author} »)
public void getByAuthor(@PathParam(« author » String author){
// Do Something
}
29
Exposé - Informatique & Réseaux
MÉTHODES HTTP : @GET, @POST, @PUT,
@DELETE
31
Exposé - Informatique & Réseaux
@PATHPARAM
@GET
@Path(« ibsn/{isbn} »)
public void getByIsbn(@PathParam(« isbn » int isbn){
System.out.println(« isbn »);
}
@GET
@Path(« author/{author} »)
public void getByAuthor(@PathParam(« author » String author){
System.out.println(« author »);
}
32
Exposé - Informatique & Réseaux
REPRÉSENTATION @CONSUMES
@PRODUCES
33
Exposé - Informatique & Réseaux
DÉMONSTRATION
34
Exposé - Informatique & Réseaux
CONCLUSION
35
Exposé - Informatique & Réseaux
Merci
Questions ?
36
Exposé - Informatique & Réseaux