introduction aux services web -...
TRANSCRIPT
![Page 1: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/1.jpg)
Introduction aux Services Web
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr1
![Page 2: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/2.jpg)
Rappel : du Web H2M au M2M
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr2
HTML
Generation 1
Static HTML
Generation 2
Web Applications
HTML
HTML
XML
HTML
XML
Generation 3
Web Services
Machine to Machine (M2M)
![Page 3: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/3.jpg)
Principes du Web Statique H2M
• Serveurs,
• Pages
• Liens hypertexte
2015-2016Internet & Services – BAT4 - Jean-Yves tigli - [email protected] -
www.tigli.fr3
NET
![Page 4: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/4.jpg)
Adressage : URL - Uniform Resource Locator• Une URL (Uniform Resource Locator) a au moins deux
champs (protocole, adresse de la ressource)– Le protocole: schéma de représentation– L’Adresse : localisation complète de la ressource– Ex:
• mailto:[email protected]• news:fr.comp.infosystemes.www.auteurs
• Une URL HTTP a au moins trois champs (protocole, adresse, emplacement) :– Le protocole: http suivi de :– L’adresse: le nom complet de la ressource // login : password @
nom domaine : port– Emplacement: Emplacement de la ressource à l’adresse– Données supplémentaires optionnelles transmises
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr4
Exemple : http://Jojo:[email protected]:8888/chemin/d/acc%C3%A8s.php?q=req&q2=req2#signet
![Page 5: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/5.jpg)
Client / Serveur Particuliers
• Page Web:• Pointés par une URL• La plupart des pages WEB se composent de:
• Une page HTML de base,• Différentes références à des « objets »
• L’agent utilisateur (client) pour le Web s’appel un “browser” (butineur en français)• Microsoft Internet Explorer, Mozilla FireFox, Opera, Safari, Google Chrome, …
• Un serveur pour le Web s’appelle un serveur Web :• Apache, Microsoft Internet Information Server (IIS), …
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr5
![Page 6: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/6.jpg)
Principes du Web Dynamique H2M
• Serveurs,
• Pages
• Liens hypertexte
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr
NET
6
![Page 7: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/7.jpg)
Adressage : Urx - Uniform Resource …
• Un URN (Uniform Resource Name) • Identifie une ressource par un nom dans un espace de nommage (identifie la
ressource et pas sa localisation)
• urn:NID:NSS
• Peu utilisé, voir Plugins spécialisés
• Plus généralement un URI (Uniform Resource Identifier)• Peut être une URL ou un URN
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr7
Référence : W3C , URIs, URLs, and URNs: Clarifications and Recommendations,
http://www.w3.org/TR/uri-clarification/
![Page 8: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/8.jpg)
Pour quoi faire ?
• Les Services Web permettent d’interconnecter :• Différentes entreprises
• Différentes applications
• Différents clients
• Différents matériels
• Utilisé dans différents cadres:• B2B (Business To Business)
• EAI (Enterprise Application Integration)
• …
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr8
![Page 9: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/9.jpg)
Deux types de Services WebWS-RESTFul & WS-SOAP
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr9
![Page 10: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/10.jpg)
Les principes REST
• Le Web aujourd’hui : extraction des ressources / ressources
• Les ressources sont identifiées par des URL
• Dénominations • Architectures Orientées Données (DOA)
• Architectures Orientées Ressources (ROA)
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr10
![Page 11: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/11.jpg)
Les principes REST
• REpresentational State Transfer
• Style architectural pas seulement dédié aux architectures orientées services et aux communication entre machines.
• Aucune hypothèse sur les protocoles impliqués, seulement des contraintes
• Les systèmes qui suivent les principes de l'architecture REST sont souvent appelés RESTful et s’appuient sur le Web
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr11
Chapitre 5 de la thèse de doctorat "Representational State Transfer (REST)". de Roy Fielding , 2000
![Page 12: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/12.jpg)
Les principes REST ou ROA
• Ressources (Identifiant)
• Entité identifiable dans le système (livre, agenda …)
• URI et donc possiblement URL
• Une URI identifie une seule Ressource
• Une Ressource peut avoir plusieurs URI
• Exemple :
• Emploi du temps de tigli : /edt/prof/tigli/lundi
• Méthodes (Verbes)
• Quatre opérations de base « CRUD » : Create (créer), Retrieve (lire), Update (mettre à jour), Delete (Supprimer)
• Exemple méthodes HTTP : GET, POST, PUT, DELETE
• Déjà adaptées à la manipulation de Ressources
• Représentation (Vue de l’état)
• Informations transférées entre client et serveur
• Exemple : XML, JSON, XHTML, CSV ….
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr12
![Page 13: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/13.jpg)
Cycle de Vie REST
• Plus récemment REST s’est doté d’un langage de description de service : WADL (Web Application Description Language)
• Soumis en 2009 au W3C, il n’est toujours pas standardisé
• Le WADL est un format de fichier basé sur XML qui permet de décrire des applications REST.
• Cette spécification se heurte néanmoins à la spécification WSDL 2.0, qui elle aussi permet la description de web services REST.
• De plus, WADL est encore très mal supporté par l'ensemble des frameworks existants ce qui limite son utilisation.
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr13
![Page 14: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/14.jpg)
REST pour une approche ROA
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr14
Serv
eur
Web
Liste des
Pièces
Détail
Pièce
Soumettre
BdC
HTTP GET URL 1
Réponse(doc XML / HTML)
Réponse(doc XML / HTML)
Réponse HTTP
Réponse HTTP
Réponse HTTP
HTTP GET URL 2
HTTP POST URL 3BdC
(XML/HTML)
URL du BdC
![Page 15: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/15.jpg)
La structure des messages WS-REST
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr15
WS-REST message
HTTP headers (URI)
Content
Message complet
Entête standard HTTP and URL
et méthode CRUD
Donnée au format JSON, XML, …
GET, POST, PUT, DELETE
Format Data
![Page 16: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/16.jpg)
Exemple RESTFul/XML
• Exemple de message HTTP RESTFul
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr16
POST http://MyService/Person/Host: MyServiceContent-Type: text/xml; charset=utf-8Content-Length: 123<?xml version="1.0" encoding="utf-8"?>
<Person><ID>1</ID><Name>M Vaqqas</Name><Email>[email protected]</Email><Country>India</Country></Person>
![Page 17: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/17.jpg)
Exemple RESTFul/JSON
• Exemple de message HTTP RESTFul
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr17
POST http://MyService/Person/Host: MyServiceContent-Type: text/xml; charset=utf-8Content-Length: 123<?xml version="1.0" encoding="utf-8"?>
{"ID": "1","Name": "M Vaqqas","Email": "[email protected]","Country": "India"
}
![Page 18: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/18.jpg)
Cycle de Vie REST
• Plus récemment REST s’est doté d’un langage de description de service : WADL (Web Application Description Language)
• Soumis en 2009 au W3C, il n’est toujours pas standardisé
• Le WADL est un format de fichier basé sur XML qui permet de décrire des applications REST.
• Cette spécification se heurte néanmoins à la spécification WSDL 2.0, qui elle aussi permet la description de web services REST.
• De plus, WADL est encore très mal supporté par l'ensemble des frameworks existants ce qui limite son utilisation.
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr18
![Page 19: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/19.jpg)
Services WebWS-SOAP
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr19
![Page 20: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/20.jpg)
SOAP pour une approche SOA
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr20
getPartsList()
getPartId()
Submit(PO)
HTTP POST
URL 1
Réponse(doc XML) Réponse HTTP
Requête(doc XML)
Serv
eur
SOA
P
Serv
eur
Web
HTTP POST
URL 1
Réponse(doc XML) Réponse HTTP
Requête(doc XML)
HTTP POST
URL 1
Réponse(doc XML) Réponse HTTP
Requête(doc XML)
![Page 21: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/21.jpg)
La structure des messages WS-SOAP
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr21
SOAP message
HTTP headers
SOAP Envelope
SOAP header
headers
SOAP body
method call & data
Message complet
Entête standard HTTP et
entête SOAP HTTP
Enveloppe
Entête
Entête individuelle
Corps contenant les appels
de méthodes SOAP
Appel de méthode et
description en XML des données
![Page 22: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/22.jpg)
Exemple de requête SOAP utilisant HTTP
• Demande de cotation à un serveur :POST /StockQuote HTTP/1.1Host: www.stockquoteserver.comContent-Type: text/xml; charset=‘’utf-8’’Content-Length: nnnnSOAP-Action: ‘’Some-URI’’
<SOAP-ENV:Envelopexmlns:SOAP-ENV=‘’http://schemas.xmlsoap.org/soap/enveloppe/’’
SOAP-ENV:encodingStyle=‘’http://schemas.xmlsoap.org/soap/encoding/’’>
<SOAP-ENV:Body><m:GetLastTradePrice xmlns:m=‘’Some-URI’’>
<symbol>DIS</symbol></m:GetLastTradePrice>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr22
Une seule commande HTTP/POST
« envoi de message SOAP»
SOAP
![Page 23: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/23.jpg)
Exemple de réponse SOAP utilisant HTTP
• Réponse du serveurHTTP/1.1 200 OKContent-Type: text/xml; charset=‘’utf-8’’Content-Length: nnnn
<SOAP-ENV:Envelopexmlns:SOAP-ENV=‘’http://schemas.xmlsoap.org/soap/envelope/’’
SOAP-ENV:encodingStyle=‘’http://schemas.xmlsoap.org/soap/encoding/’’>
<SOAP-ENV:Body><m:GetLastTradePrice xmlns:m=‘’Some-URI’’>
<Price>34.5</Price></m:GetLastTradePrice>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr23
Réponse au HTTP/POST
SOAP
![Page 24: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/24.jpg)
Cycle de Vie WS-SOAP
• Etape 1 : Déploiement du service Web• Dépendant de la plate-forme
• Etape 2 : Enregistrement du service Web• WSDL : description du service• Référentiels : DISCO (local), UDDI (global)
• Etape 3 : Découverte du service Web
• Etape 4 : Invocation du service Web par le client
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr24
![Page 25: Introduction aux Services Web - nyx.unice.frnyx.unice.fr/.../fetch.php?media=cours:introduction_aux_services_we… · Introduction aux Services Web 2015-2016 ... Principes du Web](https://reader034.vdocument.in/reader034/viewer/2022051808/600b5849764fae68d448f45f/html5/thumbnails/25.jpg)
Applications Domotiques – GTB …
• Une autre façon de voir les capteurs / actionneurs et équipements déployés dans un domicile / immeuble / quartier / ville
• Ex . WIT et son DataCenter
• Ex. HDSN en visite le 21 Mars matin et ses services REST
• Ex. Nice Côte d’Azur – ville du numérique et « big data » - Véolia / IBM
2015-2016Internet & Services – BAT4 - Jean-Yves tigli -
[email protected] - www.tigli.fr25