SlideShare uma empresa Scribd logo
1 de 62
Baixar para ler offline
Services web
     RESTful


   Raphaël Rougeron
Conférence PHPQuébec 2009
A propos de moi

    Raphaël Rougeron <goldoraf@gmail.com>



          depuis... bien longtemps !



    Expert technologies web chez



    Contributeur d'



    Framework Stato


    http://stato-framework.org
    http://raphael-rougeron.com

Avant-propos




     Je n'ai rien contre SOAP !
Principes de SOAP

    SOAP = RPC via HTTP



    Remote Procedure Call



    Invocation de méthodes d'objets distants



    Héritage de CORBA, DCOM, mais plus lourd



    Nécessite des outils (IDEs, génération WSDL)

Principe du web




  L'hypertexte permet la navigation au sein de
        nuages de données distribuées
La complexité de SOAP
La simplicité du web




          HTTP, URI, (X)HTML
The web is agreement




                  http://www.flickr.com/photos/psd/1805709102/
quot;Il existe deux manières de concevoir un logiciel.
La première, c’est de le faire si simple qu’il est
évident qu’il ne présente aucun problème. La
seconde, c’est de le faire si compliqué qu’il ne
présente aucun problème évident. La première
méthode est de loin la plus complexe.quot;
                                       C.A.R. Hoare
quot;Things should be made as simple as possible,
               but not simpler.quot;
                                 Albert Einstein
HTTP


GET / HTTP/1.1
Host: www.google.fr
User-Agent: Mozilla/5.0 (Linux; ...
Accept: text/xml,application/xml,...
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: SID=DQAAAHg.......
HTTP
    Méthode
                  Chemin

GET / HTTP/1.1
Host: www.google.fr
User-Agent: Mozilla/5.0 (Linux; ...
Accept: text/xml,application/xml,...
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
                                                       Entêtes
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: SID=DQAAAHg.......

          Corps
HTTP


HTTP/1.x 200 OK
Connection: Keep-Alive
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Server: gws
Content-Length: 2614
Date: Wed, 12 Dec 2007 08:57:47 GMT
Content-Encoding: gzip
<html><head><meta http-equiv=quot;content-typequot;
content=quot;text/html; charset=UTF-8quot;><title>Google</title>.....
HTTP

                   Code de réponse

HTTP/1.x 200 OK
Connection: Keep-Alive
Cache-Control: private
Content-Type: text/html; charset=UTF-8
                                                          Entêtes
Server: gws
Content-Length: 2614
Date: Wed, 12 Dec 2007 08:57:47 GMT
Content-Encoding: gzip
<html><head><meta http-equiv=quot;content-typequot;
content=quot;text/html; charset=UTF-8quot;><title>Google</title>.....
                        Corps
REST




       Qu'est ce que REST ?
         3 définitions possibles
Representational State Transfer

    Thèse de Roy Fielding, 2000



    Un ensemble de critères de conception, bâti sur


    4 principes simples
    L'architecture originale du web par l'un des


    pères du protocole HTTP...
    ...définie a posteriori

Services / applications RESTful




         Ce dont nous allons parler :
  Une architecture web utilisant HTTP, URI, et
        autres standards correctement
REST-RPC

    XML via HTTP sans SOAP



    Approche RPC



    Requêtes GET ou POST



    Egalement appelé quot;POXquot;





Hélas beaucoup de services étiquettés REST
tombent dans cette catégorie...
http://api.flickr.com/services/rest/?method=flickr.photos.getRecent
Principes (ou contraintes) REST
Ressources

Peuvent être n'importe quelle entité, physique ou
non !
    Un utilisateur



    Une conférence



    Une pièce mécanique



    La dernière version d'un logiciel



    Un pays

URIs et adressabilité

Donner à chaque ressource un identifiant :
    http://example.com/users/fred



    http://example.com/conference/2009



    http://example.com/products/1234



    http://example.com/downloads/latest



    http://example.com/wiki/Canada

Absence d'état

    Chaque requête HTTP est isolée des autres



    Chaque requête comprend toutes les


    informations nécessaires au serveur pour y
    répondre :
    http://example.com/fr/users/me/profile
    Conséquences heureuses :



        Mise en cache possible (proxies)
    


        Performances
    


        Scalability
    
Représentations

    XHTML



    XML



    JSON       L'idée est de retourner



            différentes représentations
    PNG


            d'une ressource en fonction
    PDF

               des souhaits du client
    YAML



    CSV



    ...

Représentations

GET /users/fred
Host: example.com
Accept: application/xml
…
<user>
  ....
</user>

GET /users/fred
Host: example.com
Accept: text/x-vcard
…
BEGIN:VCARD
  …
END:VCARD
Interface uniforme

 GET               Récupérer une information
 PUT               Modifier une ressource
                   (ou la créer si on peut deviner son URI)
 POST              Créer une sous-ressource
 DELETE            Dois-je le préciser ?


  Sans oublier HEAD et OPTIONS...
Conception RESTful
                 ou
quot;Et si on refaisait l'API de Flickr ?quot;
Flickr

GET http://api.flickr.com/services/rest/
    ?method=flickr.photos.getRecent&extras=geo,tags
GET http://api.flickr.com/services/rest/
    ?method=flickr.photos.getInfo&photo_id=12345
POST http://api.flickr.com/services/rest/
    ?method=flickr.photos.addTags
POST http://api.flickr.com/services/rest/
    ?method=flickr.photos.delete
GET http://api.flickr.com/services/rest/
    ?method=flickr.photos.comments.getList&photo_id=12345
POST http://api.flickr.com/services/rest/
    ?method=flickr.photos.comments.add
POST http://api.flickr.com/services/rest/
    ?method=flickr.photos.comments.edit
Flickr v.2.0




          1. Définir les ressources
Flickr v.2.0

    Utilisateurs



    Photos



    Tags



    Commentaires

Flickr v.2.0




    2. Nommer les ressources par des URIs
Flickr v.2.0

http://api.flickr.com/users/fred
http://api.flickr.com/users/fred/photos/recent
http://api.flickr.com/users/fred/photos/12345
http://api.flickr.com/users/fred/photos/12345/tags
http://api.flickr.com/users/fred/photos/12345/comments
Flickr v.2.0




        3. Exposer certaines méthodes
             de l'interface uniforme
Flickr v.2.0

                  Méthode      URI
                  GET          /users
                  POST         /users
                  GET          /users/fred
                  PUT          /users/fred
                  DELETE       /users/fred



        Méthode             URI
        GET                 /users/fred/photos
        GET                 /users/fred/photos/recent
        POST                /users/fred/photos
        GET                 /users/fred/photos/12345
        PUT                 /users/fred/photos/12345
        DELETE              /users/fred/photos/12345
Flickr v.2.0
        Méthode         URI
        GET             /users/fred/photos/12345/tags
        POST            /users/fred/photos/12345/tags
        PUT             /users/fred/photos/12345/tags/toto
        DELETE          /users/fred/photos/12345/tags/toto



      Méthode     URI
      GET         /users/fred/photos/12345/comments
      POST        /users/fred/photos/12345/comments
      PUT         /users/fred/photos/12345/comments/23
      DELETE      /users/fred/photos/12345/comments/23
Flickr v.2.0




         4. Définir les représentations
Flickr v.2.0

    En entrée (POST, PUT) :



        XML
    


        URL-encoded
    



    En sortie :



        XML
    


        JSON
    


        PNG|JPG|GIF
    
Flickr

<photos page=quot;2quot; pages=quot;89quot; perpage=quot;10quot; total=quot;881quot;>
   <photo id=quot;2636quot; owner=quot;47058503995@N01quot;
      secret=quot;a123456quot; server=quot;2quot; title=quot;test_04quot;
      ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; />
   <photo id=quot;2635quot; owner=quot;47058503995@N01quot;
      secret=quot;b123456quot; server=quot;2quot; title=quot;test_03quot;
      ispublic=quot;0quot; isfriend=quot;1quot; isfamily=quot;1quot; />
   <photo id=quot;2633quot; owner=quot;47058503995@N01quot;
      secret=quot;c123456quot; server=quot;2quot; title=quot;test_01quot;
      ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; />
   <photo id=quot;2610quot; owner=quot;12037949754@N01quot;
      secret=quot;d123456quot; server=quot;2quot; title=quot;00_tallquot;
      ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; />
</photos>
Flickr v.2.0




        5. Définir les réponses HTTP :
        Déroulement normal/anormal
Flickr v.2.0

    GET : 200 OK | 404 Not found



    POST : 201 Created | 409 Conflict



    PUT, DELETE : 200 0K



    Rien ne va plus : 500 Internal server error ;)

Flickr v.2.0




           6. Implémenter le tout ?

        Il reste encore un problème...
HATEOS

Hypermedia as the engine of application state

quot;A REST API should be entered with no prior knowledge beyond
the initial URI (bookmark) and set of standardized media types that
are appropriate for the intended audience (i.e., expected to be
understood by any client that might use the API). From that point
on, all application state transitions must be driven by client
selection of server-provided choices that are present in the
received representations or implied by the user’s manipulation of
those representations.quot;
                                                        Roy Fielding
Flickr



Exemple : construction des URIs vers les photos
Une documentation est nécessaire pour naviguer dans l'API !!!

http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg

http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg

http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png)
HATEOS




    Comment résoudre ce problème ?
Connexité



Ou relier les choses entre elles :

<order href=quot;http://example.com/orders/1234quot;>
  <client href=quot;http://example.com/clients/1234quot; />
  <product href=quot;http://example.com/clients/1234quot; amount=quot;2quot; />
  …
</order>
Connexité


L'exemple d'ATOM :
<?xml version=quot;1.0quot;?>
<entry xmlns=quot;http://www.w3.org/2005/Atomquot;>
    <title>Atom-Powered Blog</title>
    <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
    <updated>2008-12-13T18:30:02Z</updated>
    <author>
<name>John Doe</name>
    </author>
    <content>Some text.</content>
<link rel=quot;editquot; href=quot;http://example.com/edit/first-post.atomquot; />
<link rel=quot;alternatequot; type=quot;text/htmlquot; href=quot;http://example.com/first-
post.htmlquot;/>
</entry>
URI Templates



Proposé à l'IETF par Joe Grégorio :

http://www.google.com/search?{-join|&|q,num}
http://www.google.com/notebook/feeds/{userID}
/{prefix|/notebooks/|notebookID}{-opt|/-/|categories}{-listjoin|/|
categories}?{-join|&|updated-min,updated-max,alt,start-
index,max-results,entryID,orderby}
WADL


<resources base=quot;http://service.example.com/myservices/quot;>
   <resource path=quot;searchquot;>
     <method name=quot;GETquot; id=quot;searchquot;>
       <request>
         <param name=quot;queryquot; type=quot;xsd:stringquot; style=quot;queryquot;
required=quot;truequot;/>
       </request>
       <response>
          <representation mediaType=quot;application/xmlquot;
element=quot;yn:ResultSetquot;/>
         <fault status=quot;400quot; mediaType=quot;application/xmlquot;
element=quot;ya:Errorquot;/>
         </response>
     </method>
   </resource>
</resources>
Authentification
Authentification

    HTTP Basic



        Mot de passe en clair (base64)
    


        À n'utiliser qu'en HTTPS
    



    HTTP Digest



        Nécessite un module Apache rarement activé
    



    WSSE Username Token



        Utilisé pour Atom
    


        Algorithme SOAP ;)
    
WSSE Username Token

Serveur :
HTTP/1.1 401 Unauthorized
WWW-Authenticate: WSSE realm=quot;fooquot;, profile=quot;UsernameTokenquot;

Client :
GET /posts/recent HTTP/1.1
Host: example.com
Content-Type: application/atom+xml
Authorization: WSSE profile=quot;UsernameTokenquot;
X-WSSE: UsernameToken
  Username=quot;fredquot;,
  PasswordDigest=quot;quR/EWLAV4xLf9Zqyw4pDmfV9OY=quot;,
  Nonce=quot;d36e316282959a9ed4c89851497a717fquot;,
  Created=quot;2003-12-15T14:43:07Zquot;
WSSE Username Token



<?php

$nonce = md5(uniqid(time()));
$date = date(DATE_ATOM);
$pwd   = 'pasecure';

$digest_pwd = base64_encode(sha1($nonce.$date.$pwd));
WSSE Username Token

    Simple à implémenter



    Rien à installer (sauf peut-être pecl_http...)



    N'envoie pas les mots de passe en clair



    Empêche les quot;replay attacksquot;



    Facilement implémentable côté client Ajax

Des exemples ?
Exemples
PHP et REST
PHP et REST

    Nombreux outils XML



    json_encode, json_decode



    Extension curl pour consommer les services



    pecl_http peut aider (en-têtes)



    Un gotcha : pas de $_PUT !



$params = array();
parse_str(file_get_contents('php://input'), $params);
RESTful frameworks ?

    Tonic





    Konstrukt





    Recess





    WSO2

CakePHP
// app/config/routes.php
Router::mapResources('posts');
Router::parseExtensions();

// app/controllers/posts_controller.php
class PostsController extends AppController {
    var $components = array('RequestHandler');
    function index() {
        $posts = $this->Posts->find('all');
        $this->set(compact('posts'));
    }
    function view($id) {
        ...
    }
    function edit($id) {
                                              GET    /posts       PC::index()
        ...
    }                                         GET    /posts/123   PC::view(123)
    function delete($id) {
                                              POST   /posts       PC::add()
        ...
    }
                                              PUT    /posts/123   PC::edit(123)
}
                                            POST     /posts/123   PC::edit(123)
// app/views/posts/xml/index.ctp
                                            DELETE /posts/123     PC::delete(123)
<posts>
<?php echo $xml->serialize($posts); ?>
</posts>
Symfony

    De grands progrès en 1.2



    quot;Routes as first-class objectsquot;



    SfRequestRoute permet de préciser les


    méthodes HTTP et les représentations
    disponibles :
article:
  url:          /article/:id
  class:        sfRequestRoute
  requirements:
    sf_method: get
    sf_format: (?:xml|json|yaml)
Zend Framework

Zend_Rest_Server, un mauvais choix :
    seuls GET et POST sont supportés


    (REST-RPC)
    conçu pour retourner du XML, pas d'autre type


    de représentation possible
    problablement déprécié en 2.0, à ne pas utiliser


    pour de nouveaux projets
Zend Framework

Une autre approche :
    Profiter de l'extensibilité des composants MVC



    Zend_Controller_Request_Http supporte les


    méthodes PUT, DELETE, HEAD, OPTIONS
    Utiliser le helper d'action ContextSwitch



    Proposition de Luke Crouch :


    Zend_Controller_Router_Route_Rest
    http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Router_R
    oute_Rest+-+Luke+Crouch
Epilogue

    Soyez sceptiques



    Apprenez en plus sur REST



    Des problèmes restent à résoudre



    Retournez à la nature... du web !


Mais conteúdo relacionado

Mais procurados

Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIIMC Institute
 
Java Web Services [2/5]: Introduction to SOAP
Java Web Services [2/5]: Introduction to SOAPJava Web Services [2/5]: Introduction to SOAP
Java Web Services [2/5]: Introduction to SOAPIMC Institute
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web servicesNeil Ghosh
 
PHP and Web Services
PHP and Web ServicesPHP and Web Services
PHP and Web ServicesBruno Pedro
 
HTTP 완벽가이드 1장.
HTTP 완벽가이드 1장.HTTP 완벽가이드 1장.
HTTP 완벽가이드 1장.HyeonSeok Choi
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIRajkattamuri
 
SOAP, WSDL and UDDI
SOAP, WSDL and UDDISOAP, WSDL and UDDI
SOAP, WSDL and UDDIShahid Shaik
 
WebService-Java
WebService-JavaWebService-Java
WebService-Javahalwal
 
SOAP, UDDI, WSDL. XML definitions
SOAP, UDDI, WSDL. XML definitions SOAP, UDDI, WSDL. XML definitions
SOAP, UDDI, WSDL. XML definitions Wish Mrt'xa
 
JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5Stephan Schmidt
 
Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesIMC Institute
 
SOAP--Simple Object Access Protocol
SOAP--Simple Object Access ProtocolSOAP--Simple Object Access Protocol
SOAP--Simple Object Access ProtocolMasud Rahman
 
Working with web_services
Working with web_servicesWorking with web_services
Working with web_servicesLorna Mitchell
 
Soap web service
Soap web serviceSoap web service
Soap web serviceNITT, KAMK
 

Mais procurados (20)

Web service introduction
Web service introductionWeb service introduction
Web service introduction
 
Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDI
 
Java Web Services [2/5]: Introduction to SOAP
Java Web Services [2/5]: Introduction to SOAPJava Web Services [2/5]: Introduction to SOAP
Java Web Services [2/5]: Introduction to SOAP
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web services
 
PHP and Web Services
PHP and Web ServicesPHP and Web Services
PHP and Web Services
 
HTTP 완벽가이드 1장.
HTTP 완벽가이드 1장.HTTP 완벽가이드 1장.
HTTP 완벽가이드 1장.
 
WSDL 2.0 and Apache Woden
WSDL 2.0 and Apache WodenWSDL 2.0 and Apache Woden
WSDL 2.0 and Apache Woden
 
Java web services
Java web servicesJava web services
Java web services
 
Web service
Web serviceWeb service
Web service
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDI
 
SOAP, WSDL and UDDI
SOAP, WSDL and UDDISOAP, WSDL and UDDI
SOAP, WSDL and UDDI
 
WebService-Java
WebService-JavaWebService-Java
WebService-Java
 
Web Services
Web ServicesWeb Services
Web Services
 
SOAP, UDDI, WSDL. XML definitions
SOAP, UDDI, WSDL. XML definitions SOAP, UDDI, WSDL. XML definitions
SOAP, UDDI, WSDL. XML definitions
 
JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5
 
Web Services
Web Services Web Services
Web Services
 
Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web Services
 
SOAP--Simple Object Access Protocol
SOAP--Simple Object Access ProtocolSOAP--Simple Object Access Protocol
SOAP--Simple Object Access Protocol
 
Working with web_services
Working with web_servicesWorking with web_services
Working with web_services
 
Soap web service
Soap web serviceSoap web service
Soap web service
 

Destaque

Une RESTful Architecture
Une RESTful ArchitectureUne RESTful Architecture
Une RESTful ArchitectureBrisebois
 
Advanced designs for reusable lightning components
Advanced designs for reusable lightning componentsAdvanced designs for reusable lightning components
Advanced designs for reusable lightning componentsthomaswaud
 
Etat des lieux de la sécurisation des paiements par carte sur internet
Etat des lieux de la sécurisation des paiements par carte sur internetEtat des lieux de la sécurisation des paiements par carte sur internet
Etat des lieux de la sécurisation des paiements par carte sur internetBee_Ware
 
White paper - La sécurisation des web services
White paper - La sécurisation des web servicesWhite paper - La sécurisation des web services
White paper - La sécurisation des web servicesBee_Ware
 
La sécurité des Si en établissement de santé
La sécurité des Si en établissement de santéLa sécurité des Si en établissement de santé
La sécurité des Si en établissement de santéBee_Ware
 
ASFWS 2012 / Initiation à la sécurité des Web Services par Sylvain Maret
ASFWS 2012 / Initiation à la sécurité des Web Services par Sylvain MaretASFWS 2012 / Initiation à la sécurité des Web Services par Sylvain Maret
ASFWS 2012 / Initiation à la sécurité des Web Services par Sylvain MaretSylvain Maret
 
Journeesduweb.com Web 2.0
Journeesduweb.com Web 2.0Journeesduweb.com Web 2.0
Journeesduweb.com Web 2.0David Sévelin
 
Enquête annuelle de la franchise Banque Populaire FFF
Enquête annuelle de la franchise Banque Populaire FFFEnquête annuelle de la franchise Banque Populaire FFF
Enquête annuelle de la franchise Banque Populaire FFFulricstreit
 
Presentation Web 2.0 - ESSEC Geneve
Presentation Web 2.0 - ESSEC GenevePresentation Web 2.0 - ESSEC Geneve
Presentation Web 2.0 - ESSEC GeneveStephane Cheikh
 
RESTful API - Retour d'expérience
RESTful API - Retour d'expérienceRESTful API - Retour d'expérience
RESTful API - Retour d'expérienceChristophe Laprun
 
SophiaConf 2010 Présentation de la conférence du 30 Juin - Gestion des identi...
SophiaConf 2010 Présentation de la conférence du 30 Juin - Gestion des identi...SophiaConf 2010 Présentation de la conférence du 30 Juin - Gestion des identi...
SophiaConf 2010 Présentation de la conférence du 30 Juin - Gestion des identi...TelecomValley
 
Guide de mise en oeuvre d'une authentification forte avec une cps
Guide de mise en oeuvre d'une authentification forte avec une cpsGuide de mise en oeuvre d'une authentification forte avec une cps
Guide de mise en oeuvre d'une authentification forte avec une cpsBee_Ware
 
Où intégrer les services web (association/event)
Où intégrer les services web (association/event)Où intégrer les services web (association/event)
Où intégrer les services web (association/event)Rémi Thomas
 
Sylvain Bailly - Resume
Sylvain Bailly -  ResumeSylvain Bailly -  Resume
Sylvain Bailly - ResumeQWEB.ECO
 
How to write an to optimize content for the web?
How to write an to optimize content for the web?How to write an to optimize content for the web?
How to write an to optimize content for the web?QWEB.ECO
 
EVERYWARE the dawning age of ubiquitous computing
EVERYWARE the dawning age of ubiquitous computingEVERYWARE the dawning age of ubiquitous computing
EVERYWARE the dawning age of ubiquitous computingQWEB.ECO
 
ECR France Forum ‘03. Echanges électroniques : B2B, les outils et langages du...
ECR France Forum ‘03. Echanges électroniques : B2B, les outils et langages du...ECR France Forum ‘03. Echanges électroniques : B2B, les outils et langages du...
ECR France Forum ‘03. Echanges électroniques : B2B, les outils et langages du...ECR Community
 
Business process execution language
Business process execution languageBusiness process execution language
Business process execution languageBilel Abed
 

Destaque (20)

Une RESTful Architecture
Une RESTful ArchitectureUne RESTful Architecture
Une RESTful Architecture
 
REST presentation
REST presentationREST presentation
REST presentation
 
Advanced designs for reusable lightning components
Advanced designs for reusable lightning componentsAdvanced designs for reusable lightning components
Advanced designs for reusable lightning components
 
Etat des lieux de la sécurisation des paiements par carte sur internet
Etat des lieux de la sécurisation des paiements par carte sur internetEtat des lieux de la sécurisation des paiements par carte sur internet
Etat des lieux de la sécurisation des paiements par carte sur internet
 
White paper - La sécurisation des web services
White paper - La sécurisation des web servicesWhite paper - La sécurisation des web services
White paper - La sécurisation des web services
 
La sécurité des Si en établissement de santé
La sécurité des Si en établissement de santéLa sécurité des Si en établissement de santé
La sécurité des Si en établissement de santé
 
ASFWS 2012 / Initiation à la sécurité des Web Services par Sylvain Maret
ASFWS 2012 / Initiation à la sécurité des Web Services par Sylvain MaretASFWS 2012 / Initiation à la sécurité des Web Services par Sylvain Maret
ASFWS 2012 / Initiation à la sécurité des Web Services par Sylvain Maret
 
Journeesduweb.com Web 2.0
Journeesduweb.com Web 2.0Journeesduweb.com Web 2.0
Journeesduweb.com Web 2.0
 
Enquête annuelle de la franchise Banque Populaire FFF
Enquête annuelle de la franchise Banque Populaire FFFEnquête annuelle de la franchise Banque Populaire FFF
Enquête annuelle de la franchise Banque Populaire FFF
 
Services Web Asynchrones
Services Web AsynchronesServices Web Asynchrones
Services Web Asynchrones
 
Presentation Web 2.0 - ESSEC Geneve
Presentation Web 2.0 - ESSEC GenevePresentation Web 2.0 - ESSEC Geneve
Presentation Web 2.0 - ESSEC Geneve
 
RESTful API - Retour d'expérience
RESTful API - Retour d'expérienceRESTful API - Retour d'expérience
RESTful API - Retour d'expérience
 
SophiaConf 2010 Présentation de la conférence du 30 Juin - Gestion des identi...
SophiaConf 2010 Présentation de la conférence du 30 Juin - Gestion des identi...SophiaConf 2010 Présentation de la conférence du 30 Juin - Gestion des identi...
SophiaConf 2010 Présentation de la conférence du 30 Juin - Gestion des identi...
 
Guide de mise en oeuvre d'une authentification forte avec une cps
Guide de mise en oeuvre d'une authentification forte avec une cpsGuide de mise en oeuvre d'une authentification forte avec une cps
Guide de mise en oeuvre d'une authentification forte avec une cps
 
Où intégrer les services web (association/event)
Où intégrer les services web (association/event)Où intégrer les services web (association/event)
Où intégrer les services web (association/event)
 
Sylvain Bailly - Resume
Sylvain Bailly -  ResumeSylvain Bailly -  Resume
Sylvain Bailly - Resume
 
How to write an to optimize content for the web?
How to write an to optimize content for the web?How to write an to optimize content for the web?
How to write an to optimize content for the web?
 
EVERYWARE the dawning age of ubiquitous computing
EVERYWARE the dawning age of ubiquitous computingEVERYWARE the dawning age of ubiquitous computing
EVERYWARE the dawning age of ubiquitous computing
 
ECR France Forum ‘03. Echanges électroniques : B2B, les outils et langages du...
ECR France Forum ‘03. Echanges électroniques : B2B, les outils et langages du...ECR France Forum ‘03. Echanges électroniques : B2B, les outils et langages du...
ECR France Forum ‘03. Echanges électroniques : B2B, les outils et langages du...
 
Business process execution language
Business process execution languageBusiness process execution language
Business process execution language
 

Semelhante a Services web RESTful

REST in peace @ IPC 2012 in Mainz
REST in peace @ IPC 2012 in MainzREST in peace @ IPC 2012 in Mainz
REST in peace @ IPC 2012 in MainzAlessandro Nadalin
 
WordPress Tips and Tricks (DFW Meetup)
WordPress Tips and Tricks (DFW Meetup)WordPress Tips and Tricks (DFW Meetup)
WordPress Tips and Tricks (DFW Meetup)Stephanie Leary
 
rest3d Web3D 2014
rest3d Web3D 2014rest3d Web3D 2014
rest3d Web3D 2014Remi Arnaud
 
Plagger the duct tape of internet
Plagger the duct tape of internetPlagger the duct tape of internet
Plagger the duct tape of internetTatsuhiko Miyagawa
 
India Pr Wire May 11, 2009 Sensex Down 193 Points On Profit Booking
India Pr Wire May 11, 2009 Sensex Down 193 Points On Profit BookingIndia Pr Wire May 11, 2009 Sensex Down 193 Points On Profit Booking
India Pr Wire May 11, 2009 Sensex Down 193 Points On Profit BookingJagannadham Thunuguntla
 
The Zeitgeist Movement
The Zeitgeist MovementThe Zeitgeist Movement
The Zeitgeist Movementguest915c8c5
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsDylan Jay
 
REST Introduction (PHP London)
REST Introduction (PHP London)REST Introduction (PHP London)
REST Introduction (PHP London)Paul James
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moondavejohnson
 
Http/2 - What's it all about?
Http/2  - What's it all about?Http/2  - What's it all about?
Http/2 - What's it all about?Andy Davies
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Jeff Jones
 
前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpoMichael Zhang
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website OptimizationGerard Sychay
 
Making the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsMaking the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsBen Ramsey
 

Semelhante a Services web RESTful (20)

REST in peace @ IPC 2012 in Mainz
REST in peace @ IPC 2012 in MainzREST in peace @ IPC 2012 in Mainz
REST in peace @ IPC 2012 in Mainz
 
RESTful design
RESTful designRESTful design
RESTful design
 
WordPress Tips and Tricks (DFW Meetup)
WordPress Tips and Tricks (DFW Meetup)WordPress Tips and Tricks (DFW Meetup)
WordPress Tips and Tricks (DFW Meetup)
 
rest3d Web3D 2014
rest3d Web3D 2014rest3d Web3D 2014
rest3d Web3D 2014
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
Plagger the duct tape of internet
Plagger the duct tape of internetPlagger the duct tape of internet
Plagger the duct tape of internet
 
Talking to Web Services
Talking to Web ServicesTalking to Web Services
Talking to Web Services
 
India Pr Wire May 11, 2009 Sensex Down 193 Points On Profit Booking
India Pr Wire May 11, 2009 Sensex Down 193 Points On Profit BookingIndia Pr Wire May 11, 2009 Sensex Down 193 Points On Profit Booking
India Pr Wire May 11, 2009 Sensex Down 193 Points On Profit Booking
 
The Zeitgeist Movement
The Zeitgeist MovementThe Zeitgeist Movement
The Zeitgeist Movement
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web apps
 
Perl Dancer, FPW 2010
Perl Dancer, FPW 2010Perl Dancer, FPW 2010
Perl Dancer, FPW 2010
 
REST Introduction (PHP London)
REST Introduction (PHP London)REST Introduction (PHP London)
REST Introduction (PHP London)
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moon
 
Http/2 - What's it all about?
Http/2  - What's it all about?Http/2  - What's it all about?
Http/2 - What's it all about?
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
 
URL Design
URL DesignURL Design
URL Design
 
前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website Optimization
 
Making the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsMaking the Most of HTTP In Your Apps
Making the Most of HTTP In Your Apps
 

Mais de goldoraf

jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuerygoldoraf
 
Tester son JS, c'est possible !
Tester son JS, c'est possible !Tester son JS, c'est possible !
Tester son JS, c'est possible !goldoraf
 
Html5 : stockage local & synchronisation
Html5 : stockage local & synchronisationHtml5 : stockage local & synchronisation
Html5 : stockage local & synchronisationgoldoraf
 
Git ou le renouveau du contrôle de version
Git ou le renouveau du contrôle de versionGit ou le renouveau du contrôle de version
Git ou le renouveau du contrôle de versiongoldoraf
 
Rich Desktop Applications
Rich Desktop ApplicationsRich Desktop Applications
Rich Desktop Applicationsgoldoraf
 
Forum PHP 2007 - Methodes Agiles
Forum PHP 2007 - Methodes AgilesForum PHP 2007 - Methodes Agiles
Forum PHP 2007 - Methodes Agilesgoldoraf
 

Mais de goldoraf (7)

jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuery
 
Tester son JS, c'est possible !
Tester son JS, c'est possible !Tester son JS, c'est possible !
Tester son JS, c'est possible !
 
Ember.js
Ember.jsEmber.js
Ember.js
 
Html5 : stockage local & synchronisation
Html5 : stockage local & synchronisationHtml5 : stockage local & synchronisation
Html5 : stockage local & synchronisation
 
Git ou le renouveau du contrôle de version
Git ou le renouveau du contrôle de versionGit ou le renouveau du contrôle de version
Git ou le renouveau du contrôle de version
 
Rich Desktop Applications
Rich Desktop ApplicationsRich Desktop Applications
Rich Desktop Applications
 
Forum PHP 2007 - Methodes Agiles
Forum PHP 2007 - Methodes AgilesForum PHP 2007 - Methodes Agiles
Forum PHP 2007 - Methodes Agiles
 

Último

A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 

Último (20)

A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 

Services web RESTful

  • 1. Services web RESTful Raphaël Rougeron Conférence PHPQuébec 2009
  • 2. A propos de moi Raphaël Rougeron <goldoraf@gmail.com>  depuis... bien longtemps !  Expert technologies web chez  Contributeur d'  Framework Stato  http://stato-framework.org http://raphael-rougeron.com 
  • 3. Avant-propos Je n'ai rien contre SOAP !
  • 4. Principes de SOAP SOAP = RPC via HTTP  Remote Procedure Call  Invocation de méthodes d'objets distants  Héritage de CORBA, DCOM, mais plus lourd  Nécessite des outils (IDEs, génération WSDL) 
  • 5. Principe du web L'hypertexte permet la navigation au sein de nuages de données distribuées
  • 7. La simplicité du web HTTP, URI, (X)HTML
  • 8. The web is agreement http://www.flickr.com/photos/psd/1805709102/
  • 9. quot;Il existe deux manières de concevoir un logiciel. La première, c’est de le faire si simple qu’il est évident qu’il ne présente aucun problème. La seconde, c’est de le faire si compliqué qu’il ne présente aucun problème évident. La première méthode est de loin la plus complexe.quot; C.A.R. Hoare
  • 10. quot;Things should be made as simple as possible, but not simpler.quot; Albert Einstein
  • 11. HTTP GET / HTTP/1.1 Host: www.google.fr User-Agent: Mozilla/5.0 (Linux; ... Accept: text/xml,application/xml,... Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: SID=DQAAAHg.......
  • 12. HTTP Méthode Chemin GET / HTTP/1.1 Host: www.google.fr User-Agent: Mozilla/5.0 (Linux; ... Accept: text/xml,application/xml,... Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 Entêtes Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: SID=DQAAAHg....... Corps
  • 13. HTTP HTTP/1.x 200 OK Connection: Keep-Alive Cache-Control: private Content-Type: text/html; charset=UTF-8 Server: gws Content-Length: 2614 Date: Wed, 12 Dec 2007 08:57:47 GMT Content-Encoding: gzip <html><head><meta http-equiv=quot;content-typequot; content=quot;text/html; charset=UTF-8quot;><title>Google</title>.....
  • 14. HTTP Code de réponse HTTP/1.x 200 OK Connection: Keep-Alive Cache-Control: private Content-Type: text/html; charset=UTF-8 Entêtes Server: gws Content-Length: 2614 Date: Wed, 12 Dec 2007 08:57:47 GMT Content-Encoding: gzip <html><head><meta http-equiv=quot;content-typequot; content=quot;text/html; charset=UTF-8quot;><title>Google</title>..... Corps
  • 15. REST Qu'est ce que REST ? 3 définitions possibles
  • 16. Representational State Transfer Thèse de Roy Fielding, 2000  Un ensemble de critères de conception, bâti sur  4 principes simples L'architecture originale du web par l'un des  pères du protocole HTTP... ...définie a posteriori 
  • 17. Services / applications RESTful Ce dont nous allons parler : Une architecture web utilisant HTTP, URI, et autres standards correctement
  • 18. REST-RPC XML via HTTP sans SOAP  Approche RPC  Requêtes GET ou POST  Egalement appelé quot;POXquot;  Hélas beaucoup de services étiquettés REST tombent dans cette catégorie... http://api.flickr.com/services/rest/?method=flickr.photos.getRecent
  • 20. Ressources Peuvent être n'importe quelle entité, physique ou non ! Un utilisateur  Une conférence  Une pièce mécanique  La dernière version d'un logiciel  Un pays 
  • 21. URIs et adressabilité Donner à chaque ressource un identifiant : http://example.com/users/fred  http://example.com/conference/2009  http://example.com/products/1234  http://example.com/downloads/latest  http://example.com/wiki/Canada 
  • 22. Absence d'état Chaque requête HTTP est isolée des autres  Chaque requête comprend toutes les  informations nécessaires au serveur pour y répondre : http://example.com/fr/users/me/profile Conséquences heureuses :  Mise en cache possible (proxies)  Performances  Scalability 
  • 23. Représentations XHTML  XML  JSON L'idée est de retourner  différentes représentations PNG  d'une ressource en fonction PDF  des souhaits du client YAML  CSV  ... 
  • 24. Représentations GET /users/fred Host: example.com Accept: application/xml … <user> .... </user> GET /users/fred Host: example.com Accept: text/x-vcard … BEGIN:VCARD … END:VCARD
  • 25. Interface uniforme GET Récupérer une information PUT Modifier une ressource (ou la créer si on peut deviner son URI) POST Créer une sous-ressource DELETE Dois-je le préciser ? Sans oublier HEAD et OPTIONS...
  • 26. Conception RESTful ou quot;Et si on refaisait l'API de Flickr ?quot;
  • 27. Flickr GET http://api.flickr.com/services/rest/ ?method=flickr.photos.getRecent&extras=geo,tags GET http://api.flickr.com/services/rest/ ?method=flickr.photos.getInfo&photo_id=12345 POST http://api.flickr.com/services/rest/ ?method=flickr.photos.addTags POST http://api.flickr.com/services/rest/ ?method=flickr.photos.delete GET http://api.flickr.com/services/rest/ ?method=flickr.photos.comments.getList&photo_id=12345 POST http://api.flickr.com/services/rest/ ?method=flickr.photos.comments.add POST http://api.flickr.com/services/rest/ ?method=flickr.photos.comments.edit
  • 28. Flickr v.2.0 1. Définir les ressources
  • 29. Flickr v.2.0 Utilisateurs  Photos  Tags  Commentaires 
  • 30. Flickr v.2.0 2. Nommer les ressources par des URIs
  • 32. Flickr v.2.0 3. Exposer certaines méthodes de l'interface uniforme
  • 33. Flickr v.2.0 Méthode URI GET /users POST /users GET /users/fred PUT /users/fred DELETE /users/fred Méthode URI GET /users/fred/photos GET /users/fred/photos/recent POST /users/fred/photos GET /users/fred/photos/12345 PUT /users/fred/photos/12345 DELETE /users/fred/photos/12345
  • 34. Flickr v.2.0 Méthode URI GET /users/fred/photos/12345/tags POST /users/fred/photos/12345/tags PUT /users/fred/photos/12345/tags/toto DELETE /users/fred/photos/12345/tags/toto Méthode URI GET /users/fred/photos/12345/comments POST /users/fred/photos/12345/comments PUT /users/fred/photos/12345/comments/23 DELETE /users/fred/photos/12345/comments/23
  • 35. Flickr v.2.0 4. Définir les représentations
  • 36. Flickr v.2.0 En entrée (POST, PUT) :  XML  URL-encoded  En sortie :  XML  JSON  PNG|JPG|GIF 
  • 37. Flickr <photos page=quot;2quot; pages=quot;89quot; perpage=quot;10quot; total=quot;881quot;> <photo id=quot;2636quot; owner=quot;47058503995@N01quot; secret=quot;a123456quot; server=quot;2quot; title=quot;test_04quot; ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; /> <photo id=quot;2635quot; owner=quot;47058503995@N01quot; secret=quot;b123456quot; server=quot;2quot; title=quot;test_03quot; ispublic=quot;0quot; isfriend=quot;1quot; isfamily=quot;1quot; /> <photo id=quot;2633quot; owner=quot;47058503995@N01quot; secret=quot;c123456quot; server=quot;2quot; title=quot;test_01quot; ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; /> <photo id=quot;2610quot; owner=quot;12037949754@N01quot; secret=quot;d123456quot; server=quot;2quot; title=quot;00_tallquot; ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; /> </photos>
  • 38. Flickr v.2.0 5. Définir les réponses HTTP : Déroulement normal/anormal
  • 39. Flickr v.2.0 GET : 200 OK | 404 Not found  POST : 201 Created | 409 Conflict  PUT, DELETE : 200 0K  Rien ne va plus : 500 Internal server error ;) 
  • 40. Flickr v.2.0 6. Implémenter le tout ? Il reste encore un problème...
  • 41. HATEOS Hypermedia as the engine of application state quot;A REST API should be entered with no prior knowledge beyond the initial URI (bookmark) and set of standardized media types that are appropriate for the intended audience (i.e., expected to be understood by any client that might use the API). From that point on, all application state transitions must be driven by client selection of server-provided choices that are present in the received representations or implied by the user’s manipulation of those representations.quot; Roy Fielding
  • 42. Flickr Exemple : construction des URIs vers les photos Une documentation est nécessaire pour naviguer dans l'API !!! http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png)
  • 43. HATEOS Comment résoudre ce problème ?
  • 44. Connexité Ou relier les choses entre elles : <order href=quot;http://example.com/orders/1234quot;> <client href=quot;http://example.com/clients/1234quot; /> <product href=quot;http://example.com/clients/1234quot; amount=quot;2quot; /> … </order>
  • 45. Connexité L'exemple d'ATOM : <?xml version=quot;1.0quot;?> <entry xmlns=quot;http://www.w3.org/2005/Atomquot;> <title>Atom-Powered Blog</title> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2008-12-13T18:30:02Z</updated> <author> <name>John Doe</name> </author> <content>Some text.</content> <link rel=quot;editquot; href=quot;http://example.com/edit/first-post.atomquot; /> <link rel=quot;alternatequot; type=quot;text/htmlquot; href=quot;http://example.com/first- post.htmlquot;/> </entry>
  • 46. URI Templates Proposé à l'IETF par Joe Grégorio : http://www.google.com/search?{-join|&|q,num} http://www.google.com/notebook/feeds/{userID} /{prefix|/notebooks/|notebookID}{-opt|/-/|categories}{-listjoin|/| categories}?{-join|&|updated-min,updated-max,alt,start- index,max-results,entryID,orderby}
  • 47. WADL <resources base=quot;http://service.example.com/myservices/quot;> <resource path=quot;searchquot;> <method name=quot;GETquot; id=quot;searchquot;> <request> <param name=quot;queryquot; type=quot;xsd:stringquot; style=quot;queryquot; required=quot;truequot;/> </request> <response> <representation mediaType=quot;application/xmlquot; element=quot;yn:ResultSetquot;/> <fault status=quot;400quot; mediaType=quot;application/xmlquot; element=quot;ya:Errorquot;/> </response> </method> </resource> </resources>
  • 49. Authentification HTTP Basic  Mot de passe en clair (base64)  À n'utiliser qu'en HTTPS  HTTP Digest  Nécessite un module Apache rarement activé  WSSE Username Token  Utilisé pour Atom  Algorithme SOAP ;) 
  • 50. WSSE Username Token Serveur : HTTP/1.1 401 Unauthorized WWW-Authenticate: WSSE realm=quot;fooquot;, profile=quot;UsernameTokenquot; Client : GET /posts/recent HTTP/1.1 Host: example.com Content-Type: application/atom+xml Authorization: WSSE profile=quot;UsernameTokenquot; X-WSSE: UsernameToken Username=quot;fredquot;, PasswordDigest=quot;quR/EWLAV4xLf9Zqyw4pDmfV9OY=quot;, Nonce=quot;d36e316282959a9ed4c89851497a717fquot;, Created=quot;2003-12-15T14:43:07Zquot;
  • 51. WSSE Username Token <?php $nonce = md5(uniqid(time())); $date = date(DATE_ATOM); $pwd = 'pasecure'; $digest_pwd = base64_encode(sha1($nonce.$date.$pwd));
  • 52. WSSE Username Token Simple à implémenter  Rien à installer (sauf peut-être pecl_http...)  N'envoie pas les mots de passe en clair  Empêche les quot;replay attacksquot;  Facilement implémentable côté client Ajax 
  • 56. PHP et REST Nombreux outils XML  json_encode, json_decode  Extension curl pour consommer les services  pecl_http peut aider (en-têtes)  Un gotcha : pas de $_PUT !  $params = array(); parse_str(file_get_contents('php://input'), $params);
  • 57. RESTful frameworks ? Tonic  Konstrukt  Recess  WSO2 
  • 58. CakePHP // app/config/routes.php Router::mapResources('posts'); Router::parseExtensions(); // app/controllers/posts_controller.php class PostsController extends AppController { var $components = array('RequestHandler'); function index() { $posts = $this->Posts->find('all'); $this->set(compact('posts')); } function view($id) { ... } function edit($id) { GET /posts PC::index() ... } GET /posts/123 PC::view(123) function delete($id) { POST /posts PC::add() ... } PUT /posts/123 PC::edit(123) } POST /posts/123 PC::edit(123) // app/views/posts/xml/index.ctp DELETE /posts/123 PC::delete(123) <posts> <?php echo $xml->serialize($posts); ?> </posts>
  • 59. Symfony De grands progrès en 1.2  quot;Routes as first-class objectsquot;  SfRequestRoute permet de préciser les  méthodes HTTP et les représentations disponibles : article:   url:          /article/:id   class:        sfRequestRoute   requirements:     sf_method: get     sf_format: (?:xml|json|yaml)
  • 60. Zend Framework Zend_Rest_Server, un mauvais choix : seuls GET et POST sont supportés  (REST-RPC) conçu pour retourner du XML, pas d'autre type  de représentation possible problablement déprécié en 2.0, à ne pas utiliser  pour de nouveaux projets
  • 61. Zend Framework Une autre approche : Profiter de l'extensibilité des composants MVC  Zend_Controller_Request_Http supporte les  méthodes PUT, DELETE, HEAD, OPTIONS Utiliser le helper d'action ContextSwitch  Proposition de Luke Crouch :  Zend_Controller_Router_Route_Rest http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Router_R oute_Rest+-+Luke+Crouch
  • 62. Epilogue Soyez sceptiques  Apprenez en plus sur REST  Des problèmes restent à résoudre  Retournez à la nature... du web ! 