Introduction aux Services Web Slimane Hammoudi et Denivaldo Lopes 1
Plan Introduction aux Services Web. Le problème de l Interopérabilité entre systèmes. Les Technologies utilisées (XML, WSDL, UDDI, SOAP,...). La Composition des Services Web. Les Services Web, XML-RPC, RMI et CORBA. JWSDP (Java Web Service Developer Pack). Un exemple avec JWSDP et dotnet 2
Introduction aux Services Web 3
Un Service Web, c est quoi? Un service Web est une «unité logique applicative» accessible en utilisant les protocoles standard d Internet Une «librairie» fournissant des données et des services à d autres applications. Un objet métier qui peut être déployé et combiné sur Internet avec une faible dépendance vis-à-vis des technologies et des protocoles. Combine les meilleurs aspects du développement à base de composants et du Web. 4
Notions Les Services Web fournissent une couche d'abstraction entre le client et le fournisseur d'un service. Cette couche est indépendante de la plateforme et du langage d'implémentation. Client de Service Fournisseur de Service Code de l'applicat ion API/Stub pour accéder au Service Web Internet/ Intranet Figure 1 Services Web Service Web Code de l'applicat ion 5
Atoûts des services Web Réutilisabilité Interopérabilité - indépendance de: la Plate-forme (Hardware et Système d Exploitation, e.g. Pentium avec Windows, Sparc avec Sun Solaris, PowerPc avec AIX, Pentium avec Linux,..) l'implémentation (Java, C#, C++,...) l'environnement de développement (J2EE, dotnet,...) 6
Les Générations des applications Web 1 Génération - Pages Web statiques (HTML) 2 Génération - Des applications réelles (Pages Web dynamiques, e.g. CGI, Servlets, ASP, JSP, PHP,...) 3 Génération - Les Services Web (basé sur XML) 7
L'évolution du Web (selon ORFALI) fonction Introduction aux Services Web HiperText Web Réponse simple dans la Web L Objet Web Les Services Web Publication Électronique Formulaires Complet Client/Serveur Client/Serveur basé sur XML Serveur de fichier basé sur URL Formulaire CGI Tableau ISAPI NSAPI HTML Dynamique Scripts Cookies/Sessions ASPs CORBA plug-ins (WAI) Push WebObjects Servlets, JSP, PHP JavaBeans/Applet ActiveX Controls Interactions basées sur ORB via CORBA et DCOM XML SOAP WSDL UDDI ActiveXML Ne figure pas dans l'ouvrage de ORFALI Figure 2 Evolution du Web Interaction 8
Le problème de l Interopérabilité entre systèmes. 9
Le Problème de l'interoperabilité Applic. (AppleScript) OS X PowerPC G5 Application (C#) Windows XP Pentium III Application (C++) Linux Pentium IV Application (C) AIX (IBM) PowerPC Internet/ Intranet Application (Java) Windows 2000 Pentium IV Application (C#) Windows CE Application (C++) Sun Solaris Sun Enterprise10K (Mainframe) Application (J2EE) z/os IBM z900 (Mainframe) Figure 3 Le Problème de l Interopérabilité 10
Les Services Web assurent: Interopérabilité: Différentes Applications (Client et/ou Serveur) Différents Systèmes d Exploitation Différents Hardwares Distribution et Intégration des logiques métiers Faible couplage Protocoles plus adaptés au Web La plus importante innovation des Services Web est l'utilisation de XML comme EDI 11
Les Principales Technologies des Services Web (XML, WSDL, UDDI, SOAP,...). 12
Les quatre principales technologies des Services Web extensible Markup Language (XML); Simple Object Access Protocol (SOAP); Web Services Description Language (WSDL); Universal Description, Discovery and Integration (UDDI) Note: HTTP, SMTP/MIME, MOM/JMS ou tout autre protocol peuvent être utilisés comme protocoles de transport 13
Les principaux acteurs Message en Soap/HTTP Demandeur de services Message en Soap Call Bind Search ournisseur e services Services Publish Message en Soap WSDL des Services Figure 4 Les principaux acteurs des Services Web Serveur UDDI Annuaire de Services Web 14
La description des Services Web -Comment décrire le contrat entre le client et le serveur? WSDL est un langage qui permet de décrire: - un service Web - et comment l invoquer 15
WSDL en détail WSDL permet la représentation d'un Service Web de manière plus abstraite pour la réutilisation. Structure de WSDL: <?xml version="1.0" encoding="utf-8"?> <definitions> <types>!--abstract data types</types> <message>!--message structure</message> <porttype>!--web Service Interface</portType> <binding>!--how the service is accessed</binding> <service>!--who provides the service</service> </definitions> 16
La publication des services Web - Comment disponibiliser les services au monde extérieur? UDDI est un annuaire qui permet: - l enregistrement des services. - la découverte des informations sur les services. 17
UDDI en détail Une structure de données basée sur XML pour faciliter la découverte des services (XML Schema). Similaire à la figure (ci-dessous). UDDI Page blanche (pour trouver un service par contact, nom et adresse) Page Jaune (pour trouver un service par sujet basé sur taxonomies standards) Page vert (pour trouver un service par caractéristiques techniques) Figure 5 L'annuaire UDDI 18
UDDI en détail businessentity: informations sur la partie qui publie les informations sur le service tmodel: Déscription des spécifications pour services ou taxonomies. businessservice: informations déscriptives sur une famille particuliere de services bindingtemplate: information technique sur le point d'entrer et spécification de constructions BindingTemplates ont réferences pour tmodels. Ces réferences désignent les spécifications des interfaces pour un service. Figure 6 Structure de donnée d'un enregistrement de UDDI 19
Les messages Comment appeler et obtenir le résultat d'un service Web? SOAP est un protocole de transmission de messages: il est particulièrement utile pour exécuter des dialogues requête-réponse RPC (Remote Procedure Call) 20
SOAP (Simple Object Access Protocol) SOAP est un protocole léger pour accomplir la transmission des informations structurées dans une environnement distribué et décentralisé [W3C]. Le protocole SOAP définit: Une enveloppe; une mise en œuvre sur HTTP (HTTP Extension Framework); Un ensemble de règles de codages; Un fonctionnement en modèle client / serveur (RPC) 21
La Structure d un Message SOAP SOAP Message HTTP Headers SOAP Envelope SOAP Header Headers Le message SOAP Entête Standard HTTP et entête SOAP HTTP Envelope Entête Entête individulle SOAP Body Method Call and Data Figure 7 Structure d'un message SOAP Corps du message SOAP Appel de méthode et description de données 22
Résumé d un Services Web Annuaire UDDI UDDI UDDI (XML) (XML) 1 : Le fournisseur de service Web publie ses Services Web UDDI UDDI (XML) (XML) 3 : L annuaire a trouvé un service avec les caractéristiques X, Z et Y, il envoie l information du serveur qui le héberge 4 : Quel est le contrat du service Web que tu proposes? 2 : Le client recherche un service WEB avec les characteristics X, Z et Y Client WSDL WSDL (XML) (XML) 6 : J appel ton service Web SOAP SOAP (XML) (XML) 5 : Voici mon format d appel SOAP SOAP (XML) (XML) 7 : Voici le résultat du service Web Serveur
La Composition de Services Web
Les entreprises et le e-business Internet Serveurs Web Clients Serveurs Figure 8 Les entreprises, les e-business et les clients 25
Composition de Services Web Serveur Web Agence de tourisme Internet Serveurs Web Clients Serveurs Figure 8 L'angence de tourisme comme composition de services Web 26
Composition de Services Web avec le Workflow XLANG (Web Services for Business Process Design) (http://www.ebpml.org/xlang.html) WSFL (Web Services Flow Language) (http://www-3.ibm.com/software/solutions/webservices/pdf/wsfl.pdf) BPML (Business Process Modeling Language) (http://www.bpmi.org/bpml.esp) WSCI (Web Services Choreography Interface) (http://wwws.sun.com/software/xml/developers/wsci)
Un comparatif entre les Services Web, XML-RPC, RMI et CORBA
Les Services Web et XML-RPC La Pile de Service Web WSDL UDDI SOAP Message XML HTTP TCP/IP La Pile de XML-RPC ---- ---- XML-RPC Protocol XML HTTP TCP/IP 29
Les Services Web et Java RMI La Pile de Service Web WSDL UDDI SOAP Message XML HTTP TCP/IP La Pile de Java RMI ---- ---- (+/- rmiregistry) JRMP Serialization rmi TCP/IP 30
Les Services Web et CORBA La Pile de Service Web WSDL UDDI SOAP Message XML HTTP TCP/IP La Pile de CORBA IDL CORBA Services CORBA Stubs/Skeletons CDR binary representation GIOP/IIOP TCP/IP 31
Les Outils de Développements des Services Web 32
Les Outils de développements des Services Web - Java Web Service Developer Pack (JWSDP) -> Sun (Java) -> JVM http://java.sun.com/webservices/index.html -.NET -> Microsoft (C#, VB.NET, ) -> Windows http://msdn.microsoft.com/webservices - Axis -> Apache (Java et C++) -> JVM http://ws.apache.org/axis/cpp/index.html - gsoap -> Robert van Engelen (C/C++) Win, Linux, Unix (SunSolaris, SGI IRIX), Mac OS X http://www.cs.fsu.edu/~engelen/soap.html -- IBM WebSphere SDK for Web Services -> IBM (Java) ->JVM http://www-106.ibm.com/developerworks/webservices/wsdk 33
Un exemple avec JWSDP et.net 34
Exemple de Services Web Hello World! (modélisation) Service 1 Message: String HelloWorld(i_am: String): String Consumer I_am : String Invoke_service() : void Figure 8 Diagramme de Classe Service 1 Consumer 1: HelloWorld(param:String) 2: return (msg:string) Figure 9 Diagramme de séquence 35
Hello World en C# (Implementation) using System; using System.Web; using System.Web.Services; // other using namespace WebService_demo { public class Service1 : System.Web.Services.WebService { public Service1() { message= "I am C# (.NET) in Windows! "; InitializeComponent(); } private IContainer components = null; private void InitializeComponent(){ } protected override void Dispose( bool disposing ) { if(disposing && components!= null) { components.dispose(); } base.dispose(disposing); } } } [WebMethod] public string HelloWorld(string i_am) { return i_am+message; } public string message; 36
WSDL en détail WSDL permet la représentation du service Hello World de manière plus abstraite pour permettre la réutilisation. Structure de WSDL: <?xml version="1.0" encoding="utf-8"?> <definitions> <types>!--abstract data types</types> <message>!--message structure</message> <porttype>!--web Service Interface</portType> <binding>!--how the service is accessed</binding> <service>!--who provides the service</service> 37 </definitions>
WSDL de Hello World <definitions> et <types> <?xml version="1.0" encoding="utf-8"?> <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/xmlschema" xmlns:s0="http://tempuri.org/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textmatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetnamespace="http://tempuri.org/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <types> <s:schema elementformdefault="qualified" targetnamespace="http://tempuri.org/"> <s:element name="helloworld"> <s:complextype> <s:sequence> <s:element minoccurs="0" maxoccurs="1" name="i_am" type="s:string" /> </s:sequence> </s:complextype> </s:element> <s:element name="helloworldresponse"> <s:complextype> <s:sequence> <s:element minoccurs="0" maxoccurs="1" name="helloworldresult" type="s:string" /> </s:sequence> </s:complextype> </s:element> <s:element name="string" nillable="true" type="s:string" /> </s:schema> </types> Introduction aux Services Web 38
WSDL de Hello World <message> <message name="helloworldsoapin"> <part name="parameters" element="s0:helloworld" /> </message> <message name="helloworldsoapout"> <part name="parameters" element="s0:helloworldresponse" /> </message> <message name="helloworldhttpgetin"> <part name="i_am" type="s:string" /> </message> <message name="helloworldhttpgetout"> <part name="body" element="s0:string" /> </message> <message name="helloworldhttppostin"> <part name="i_am" type="s:string" /> </message> <message name="helloworldhttppostout"> <part name="body" element="s0:string" /> </message> 39
WSDL de Hello World <porttype> <porttype name="service1soap"> <operation name="helloworld"> <input message="s0:helloworldsoapin" /> <output message="s0:helloworldsoapout" /> </operation> </porttype> <porttype name="service1httpget"> <operation name="helloworld"> <input message="s0:helloworldhttpgetin" /> <output message="s0:helloworldhttpgetout" /> </operation> </porttype> <porttype name="service1httppost"> <operation name="helloworld"> <input message="s0:helloworldhttppostin" /> <output message="s0:helloworldhttppostout" /> </operation> </porttype> Introduction aux Services Web 40
WSDL de Hello World <binding> <binding name="service1soap" type="s0:service1soap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <operation name="helloworld"> <soap:operation soapaction="http://tempuri.org/helloworld" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> </binding> <binding name="service1httpget" type="s0:service1httpget"> <http:binding verb="get" /> <operation name="helloworld"> <http:operation location="/helloworld" /> <input> <http:urlencoded /> </input> <output> <mime:mimexml part="body" /> </output> Introduction aux Services Web 41
WSDL de Hello World <binding> <binding name="service1httppost" type="s0:service1httppost"> <http:binding verb="post" /> <operation name="helloworld"> <http:operation location="/helloworld" /> <input> <mime:content type="application/x-www-form-urlencoded" /> </input> <output> <mime:mimexml part="body" /> </output> </operation> </binding> 42
WSDL de Hello World <service> <service name="service1"> <port name="service1soap" binding="s0:service1soap"> <soap:address location="http://pc-lopes:1050/webservice_demo/service1.asmx" /> </port> <port name="service1httpget" binding="s0:service1httpget"> <http:address location="http://pc-lopes:1050/webservice_demo/service1.asmx" /> </port> <port name="service1httppost" binding="s0:service1httppost"> <http:address location="http://pc-lopes:1050/webservice_demo/service1.asmx" /> </port> </service> </definitions> 43
UDDI en détail Une structure de donné basée sur XML pour faciliter la découverte de services (XML Schema). Similaire à la figure 10. UDDI Page blanche (pour trouver un service par contact, nom et adresse) Page Jaune (pour trouver un service par sujet basé sur taxonomies standards) Page vert (pour trouver un service par caractéristiques techniques) Figure 10 L'annuaire UDDI 44
UDDI en détail Access URI: http://localhost:8080/hello-jaxrpc/hello?wsdl Figure 11 Example d'un enregistrement sur UDDI avec JAXR Registry Browser 45
Client de Hello World en Java (JAX-RPC) package consumer; import service_stub.*; import javax.xml.rpc.stub; public class Client_hello{ public static void main(string[] args) { System.out.println("Invoking the Web Service Hello World..." ); invoque_service(); } private static Stub createproxy() { return (Stub)(new Service1_Impl().getService1Soap()); } private static void invoque_service() { try { Stub stub = createproxy(); Service1Soap service_helloworld = (Service1Soap)stub; System.out.println( service_helloworld.helloworld( "Hello World! I am Java (JWSDP) in Linux and are you?" ) } catch (Exception ex) { ex.printstacktrace(); } } } 46
Exécution de Hello World Services Service 1 Consumer Client Message: String I_am : String HelloWorld(i_am: String): String Invoke_service() : void Fournisseur de services Appel en Soap/HTTP Demandeur de services JWSDP Réponse en Soap/HTTP Hello World! I am Java (JWSDP) in Linux and are you? Hello World! I am Java (JWSDP) in Linux and are you? I am C# (.NET) in Windows! Figure 12 Exécution du Service Hello World avec.net et client avec JWSDP 47
La Structure du message SOAP SOAP Message HTTP Headers SOAP Envelope SOAP Header Headers Le message SOAP Entête Standard HTTP et entête SOAP HTTP Enveloppe Entête Entêtes individulles SOAP Body Method Call and Data Figure 13 Structure d'un message SOAP Corps de la message SOAP Appel de méthode et description de données 48
Le message en SOAP (Appel à distance) POST /WebService_demo/Service1.asmx HTTP/1.1 Content-Type: text/xml; charset="utf-8" Content-Length: 520 SOAPAction: "http://tempuri.org/helloworld" User-Agent: Java/1.4.1 Host: 192.168.10.56:1050 Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Connection: keep-alive <?xml version="1.0" encoding="utf-8"?> <env:envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://tempuri.org/" env:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"> <env:body> <ns0:helloworld env:encodingstyle=""> <ns0:i_am>hello World! I am Java (JWSDP) in Linux and are you?</ns0:i_am> </ns0:helloworld> </env:body> 49 </env:envelope>
Le message en SOAP (Réponse) HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/"> Hello World! I am Java (JWSDP) in Linux and who are you? I am C# (.NET) in Windows! </string> 50
JWSDP (Java Web Services Developer Pack) 51
JWSDP (Java Web Services Developer Pack) Java API for XML Binding (JAXB) Java API for XML Messaging (JAXM) Soap with Attachments API for Java (SAAJ) Java API for XML Processing (JAXP) Java API for XML Registries (JAXR) Java API for XML-based RPC (JAX-RPC) JavaServer PagesTM Standard Tag Library (JSTL) Tomcat (Java servlet and JavaServer Pages container) Administration Tool Web Application Manager Ant build tool Registry Server 52
Tomcat Web Server Container pour: Servlets, Java Server Pages, Web Services, Enterprise Java Beans,... 53
Tomcat Figure 14 Serveur Tomcat 54
Tomcat Figure 15 Serveur Tomcat (Internal Services) 55
Tomcat Figure 16 Serveur Tomcat (Java Web Services Developer Pack) 56
Tomcat Figure 17 Serveur Tomcat (Resources et User Definition) 57
Web Applications et l'architecture 3-Tier Client Tier (a.k.a Front End) (Thin Client) Enterprise Tier (a.k.a Middle Tier) Client Web Browser Workstation PC HTML Pages - dynamically generated Business Logic Servers It can be a pocket-pc, etc Internet/Intranet Servlets, ASP.NET, JavaServerPages, PHP, etc Web Servers (Apache Tomcat, IIS Microsoft, etc) DataBase Tier (a.k.a Back End) Oracle Mainframe MySQL Pentium Linux Other DBs Orther servers Figure 18 L'Architecutre Three-Tier thin client 58
Web Applications et l'architecture 4-Tier User Tier (a.k.a Client End) Workspace Tier (a.k.a Interaction Tier) Client User Presentation Workstation PC User Interaction Logic Servers Enterprise Tier (a.k.a Business Tier) Resource Tier (a.k.a Integration Tier) Resource Adapters Oracle DB Business Logic Servers Application Adapters Legacy System Mainframe DB Mainframe Figure 19 L'Architecutre Four-Tier 59
Un autre exemple de Services Web Un convertiseur d'argent Figure 20 Le cas d'utilisation du Service Web Composite
Un convertiseur d'argent Introduction aux Services Web Figure 21 Le diagramme de classe
L'Architecture Client Client Tier Mozzila Windows XP - Intel Internet/Intranet Enterprise Tier HTML dynamically generated with Servlet JWSDP- Tomcat Linux - Intel It uses JDBC to access the DB Oracle 8i Intranet DataBase Tier Oracle Linux - Intel 62 Figure 22 L'architecture 3-tier thin client du convertiseur d'argent
Exemple de l'exécution du Service Web Figure 23 Le Service Web Universal Converter 63
Conclusion: - Les Points forts des Services WEB XML comme Electronique Data Interchange (EDI) Le Web comme l environnent de développement Il utilise les standards de W3C et OASIS Interopérabilité La modularité et l extensibilité des aspects: choix du protocole de communication synchrone/asynchrone 64
Bibliographie Introduction aux Services Web Extensible Markup Language (XML), W3C (http://www.w3.org/xml/) Simple Object Access Protocol (SOAP) 1.1, W3C Submission, May, 2001. (http://www.w3.org/tr/soap/) UDDI Project, UDDI Technical White Paper, September 2000. Web Services Description Language (WSDL) 1.1, W3C Note, March 2001. (http://www.w3.org/tr/wsdl) Common Object Request Broker Architecture (CORBA), OMG (http://www.omg.org) dotnet, Microsoft (http://www.microsoft.com/net) (http://www.dotnet-fr.org) Java Web Service Developer Pack 1.1 (JWSDP), Sun Microsystems (http://java.sun.com/webservices/archive.html) -> JWSDP version 1.1 (http://java.sun.com/webservices) -> JWSDP last version 65
Bibliographie Introduction aux Services Web XML-RPC Protocol, (http://www.xmlrpc.com) Java RMI, Sun Microsystems (http://java.sun.com/products/jdk/rmi) JDBC, Sun Microsystems (http://java.sun.com/products/jdbc) HyperTest Markup Language (HTML), W3C (http://www.w3.org/markup) Servlet, Sun Microsystems (http://java.sun.com/products/servlet) SQL, (http://www.sql.org) Oracle 8i, Oracle (http://www.oracle.com) 66
Bibliographie Introduction aux Services Web Alex Ferrata and Matthew MacDonald, Programming.NET Web Services, O'Reilly, September 2002. ISBN: 0-596-00250-5 Simon St. Laurent, Joe Johnston, et al., Programming Web Services with XML-RPC, O'Reilly, June 2001. ISBN: 0-596-00119-3 David A. Chappell and Tyler Jewell, Java Web Services, O'Reilly, March 2002. ISBN: 0-596-00269-6 Ethan Cerami, Web Services Essentials Distributed Applications with XML-RPC, SOAP, UDDI and WSDL, O'Reilly, February 2002. ISBN: 0-596-00224-6 James Snell, Doug Tidwell and Pavel Kulchenko, Programming Web Services with SOAP Building Distributed Applications, O'Reilly, January 2002. ISBN: 0-596-00095-2 George Reese, Database Programming with JDBC and Java, Second Edition, 2 nd Edition 2000, O'Reilly, 2000. ISBN: 1-56592-616-1 67
MERCI de votre Attention! 68