Commerce électronique, Université de technologie de Troyes, Avril 2007 Services Web pour le commerce électronique Aurélien Bénel Systèmes d'information, management des connaissances et communication Bureau T107, aurelien.benel@utt.fr
Remue-méninges 2 Un «service»? Qu est-ce que c est? Du point de vue de l informaticien? Du point de vue du commerçant? «Web»? Quelles technologies? Par opposition à quoi? Inconvénients? Avantages?
Un même service «à toutes les sauces» Client riche 3 Service Ressources Passerelle Client léger
Exemple de chaîne de services 4 Producteur Détaillant Consommateur Grossiste Consommateur Producteur Détaillant Consommateur
There is more than one way to do it 5 SOAP («simple object access protocol») : Des messages sous enveloppes Approche fonctionnelle (RPC), Description, découverte et intégration de services (WSDL, UDDI). REST («representational state transfer») : Se reposer sur le Web Une méthodologie à suivre
Méthodologie REST : Etude de cas 6 URI Objets? Classes? XML Associations? Attributs? HTTP Méthodes?
Quels objets? 7 M. Aurélien Bénel À l UTT Commande n 41104121792V Commande n 60329154558V 1 3 1 PC133 DIMM 512Mo SDRAM PC Extreme V10 Diagramme d instances (UML)
De quelles classes? 8 M. Aurélien Bénel : Client À l UTT : AdresseLivraison Commande n 41104121792V : Commande Commande n 60329154558V : Commande 1 : LigneCommande 3 : LigneCommande 1: LigneCommande PC133 DIMM 512Mo SDRAM : Produit PC Extreme V10 : Produit Diagramme d instances (UML)
Quelles URI? 9 http://.../client/aurelien.benel http://.../adresselivraison/753 http://.../commande/41104121792v http://.../commande/60329154558v http://.../produit/4512 http://.../produit/7894 Diagramme d instances (UML)
http://.../client/aurelien.benel 10 Commande n 60329154558V : Commande M. Aurélien Bénel : Client nomcomplet = M. Aurélien Bénel adressefacturation = 7 impasse adresseelectronique = aurelien.benel@laposte.net telephone = 03 25 73 87 86 <?xml version="1.0" encoding="utf-8"?> <client nomcomplet = "M. Aurélien Bénel" adressefacturation="7 impasse " adresseelectronique="aurelien.benel@laposte.net" telephone = "03 25 73 87 86" > <commande href="http://.../commande/41104121792"> 04/11/2004 (50,49 ) </commande> <commande href="http://.../commande/60329154558v" > 29/03/2006 (1353,85 ) </commande> </client> Commande n 41104121792V : Commande Diagramme d instances (UML)
http://.../produit/4512 11 Commande n 41104121792V : Commande 1 : LigneCommande quantité="1" prixunitaire="33.88" PC133 DIMM 512Mo SDRAM : Produit intitulé="pc133 DIMM 512Mo SDRAM" constructeur="(générique)" catégorie="mémoire PC" prixunitaire="37.54" <?xml version="1.0" encoding="utf-8"?> <produit intitulé= "PC133 DIMM 512Mo SDRAM" constructeur="(générique)" catégorie="mémoire PC" prixunitaire="37.54" > <lignecommande quantité="1" prixunitaire="33.88" href="http://.../commande/41104121792" > 04/11/2004 (Troyes) </lignecommande> <lignecommande quantité="3" prixunitaire="37.54" href="http://.../commande/60329154558v" > 29/03/2006 (Troyes) </lignecommande> </produit> 3 : LigneCommande quantité="1" prixunitaire= 37.54" Commande n 60329154558V Diagramme d instances (UML)
http://.../commande/60329154558v 12 M. Aurélien Bénel : Client Commande n 60329154558V : Commande date="29/03/2006" fraisexpedition="3.336" modepaiement="cb" 3 : LigneCommande quantité="3" prixunitaire="37.54" 1: LigneCommande quantité="1" prixunitaire="1353.85" <?xml version="1.0" encoding="utf-8"?> <commande date="29/03/2006" fraisexpedition="3.336" modepaiement="cb" > <client href="http://.../client/aurelien.benel" > M. Aurélien Bénel </client> <lignecommande quantité="1" prixunitaire="1353.85" href="http://.../produit/7894" > PC Extreme V10 </lignecommande> <lignecommande quantité="3" prixunitaire="37.54" href="http://.../produit/4512" > PC133 DIMM 512Mo SDRAM </lignecommande> </client> PC133 DIMM 512Mo SDRAM : Produit Diagramme d instances (UML) PC Extreme V10 : Produit
Méthodes HTTP? 13 GET POST PUT DELETE 200 OK 201 Created Location xxx 205 Reset content 400 Bad request 403 Forbidden Intégrité référentielle Intégrité référentielle Intégrité référentielle Autorisations Autorisations Autorisations 404 Not found 500 Internal error
Et après? 14 Conception URI Objets? Classes? XML Associations? Attributs? HTTP Méthodes? Programmation Stocker les données dans une base de données Programmer les conversions BD XML (ex : en PHP) Rediriger les appels de méthodes vers les programmes correspondants
En fin de compte 15 Client riche Service Ressources Passerelle Client léger
Bibliographie 16 Berners-Lee T., Fielding R., Masinter L., Uniform Resource Identifier (URI): Generic Syntax, RFC 3986, The Internet Society, January 2005. Available on: <http://www.ietf.org/rfc/rfc3986.txt> Costello R. L., Building Web Services the REST Way. Available on: <http://www.xfront.com/rest- Web-Services.html> Fielding R., Gettys J., Mogul J., Frystyk H., Masinter L., Leach P., Berners-Lee T., Hypertext Transfer Protocol HTTP/1.1, RFC 2616, The Internet Society, June 1999. Available on: <http://www.ietf.org/rfc/rfc2616.txt> Fielding R., Architectural Styles and the Design of Network-based Software Architectures, PhD thesis, University of California, Irvine, 2002. Available on: <http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm> Gregorio J., How to Create a REST Protocol. Available on: <http://www.xml.com/lpt/a/2004/12/01/restful-web.html> Zhou C., Lejeune C., Bénel A., Towards a standard protocol for community-driven organizations of knowledge, In: Proceedings of the thirteenth international conference on Concurrent Engineering, Antibes, September 18-22, 2006. Frontiers in Artificial Intelligence and Applications, vol. 143. Amsterdam: IOS Press, 2006. p.438-449. Available on: <http://benel.techcico.fr/publi/zhou_ce_06.pdf>