Créer une architecture distribuée .NET
Transcription
Créer une architecture distribuée .NET
Ingénieurs 2000 Exposé Système & Réseaux 2006/2007 Steven JABBOUR IR3 Créer une architecture distribuée .NET Concepts et exemples Plan Plan 1. Le Framework .NET 1. Présentation du Framework .NET 2. Services Web 2. Créer et utiliser des services Web 3. .NET Remoting 4. IIOP .NET 3. Comment créer des objets distribués à l’aide de .NET Remoting ? Questions Steven JABBOUR 4. Communiquer entre Java et .NET IR3 2 Qu’est-ce que .NET ? Plan 1. Le Framework .NET .NET ensemble de technologies basé sur 4 composants : les périphériques clients (pc, pda, etc.), 2. Services Web les services Web fondamentaux (.NET Passport, exemple avec MSN), 3. .NET Remoting les outils : .NET Framework, Visual Studio .NET, les serveurs : .NET Entreprise Server. 4. IIOP .NET Questions Steven JABBOUR IR3 3 Le Framework .NET Plan Une machine virtuelle CLR (Common Language Runtime). Pas de code natif : utilisation d’un langage intermédiaire le MSIL (MicroSoft Intermediate Language). Support de 51 langages de programmation (C#, J#, VB.NET, COBOL, Perl, Python, etc.). L’introduction d’un nouveau langage C# (entre C++ et Java) Une bibliothèque de classes extensibles, regroupées par namespace en C# 1. Le Framework .NET 2. Services Web 3. .NET Remoting 4. IIOP .NET Questions Steven JABBOUR IR3 4 L’environnement de développement Plan 1. Le Framework .NET 2. Services Web Installer le Framework .NET SDK. Utiliser un éditeur et l’aide en ligne MSDN. 3. .NET Remoting Déploiement au sein du répertoire 4. IIOP .NET Questions Steven JABBOUR IR3 d'exécution de l’application, ou dans le GAC (Global Assembly Cache) ou dans le Download Cache pour les programmes télechargés. Lancer l’application ☺. 5 .NET Framework et Linux Plan 1. Le Framework .NET 2. Services Web Début du « portage » du framework .Net Différents projets : Mono par le créateur de gnome 3. .NET Remoting 4. IIOP .NET Questions V1.1 et v2.0 partiellement supportée GNU Portable DotNet Rotor (FreeBSD) Module pour Apache (mod_mono) Ouverture des standards via CLI Steven JABBOUR (Common Language Infrastructure) IR3 6 Comprendre les services web XML Plan 1. Le Framework .NET Qu’est-ce qu’un service web? 2. Services Web Dans quel cas l’utiliser? 3. .NET Remoting 4. IIOP .NET Questions Un peu de vocabulaire SOAP (Simple Object Access Protocol) WSDL (Web Service Definition Language) UDDI (Universal Description, Discovery and Integration) La mise en œuvre sous .NET … Steven JABBOUR IR3 7 Créer un service Web .NET (1/2) Déclarer un service Web (.ASMX) Plan 1. Le Framework .NET 2. Services Web 3. .NET Remoting Créer la classe du service Web 4. IIOP .NET Questions Steven JABBOUR IR3 <%@ WebService Class="NomEspaceDeNom.NomClasse, NomAssemblage" %> 1 fichier ASMX associé à une seule classe Hériter de System.Web.Services.WebService Spécifier l'espace de noms XML [WebService(Namespace=http://bill.com)] Exposer des "Web" méthodes [WebMethod(Description="Hello world")] Un service web peut renvoyer ou accepter en entrée des types primitifs (string, int…) ou complexes (Classes : XmlDocument, DataSet; Structures …) sérialisés avec SOAP sinon avec HTTP GET ou HTTP POST uniquement des string 8 Créer un service Web .NET (2/2) Plan 1. Le Framework .NET 2. Services Web 3. .NET Remoting Publier le service web Solution simple : diffusion interne via l'URL Solutions basées sur Internet : Publier via un document de découverte XML .disco de manière statique, – http://<host>/<url>/<fichier>.asmx?DISCO – Découverte dynamique via fichier .vsdisco Publier via le service UDDI 4. IIOP .NET Questions Steven JABBOUR IR3 Test dans un navigateur du service web Affichage de la documentation http://<host>/<url>/<fichier>.asmx Description de service Web (.wsdl) http://<host>/<url>/<fichier>.asmx?WSDL 9 Utiliser un service web (1/2) Plan 1. Le Framework .NET 2. Services Web 3. .NET Remoting 4. IIOP .NET Localiser un service web Soit par les fichiers .disco (disco.exe) Soit par les services UDDI Créer une classe proxy pour le service web générer par Visual Studio ou utiliser wsdl.exe fourni avec le framework. Questions Steven JABBOUR IR3 10 Utiliser un service web (2/2) Plan 1. Le Framework .NET 2. Services Web 3. .NET Remoting Créer d’un formulaire Web client utilisant le web service HelloWorld Créer un fichier nommé Hello.aspx Copier l’assemblage du web service sous bin Ajout des imports nécessaires à la page Modification du call-back Page_Load Test du résultat dans un navigateur 4. IIOP .NET Créer une application console client Questions Steven JABBOUR IR3 utilisant un web service récupérant des données en base Démonstration et test ☺ 11 Présentation de .NET Remoting Plan 1. Le Framework .NET Qu’est-ce que .NET Remoting? 2. Services Web Dans quel cas l’employer? 3. .NET Remoting 4. IIOP .NET Questions Steven JABBOUR IR3 12 Créer un objet Hello distribué Création de l’objet servant Plan 1. Le Framework .NET 2. Services Web 3. .NET Remoting class HelloServant : MarshalByRefObject Ouvrir un canal et publier l'objet sur le serveur TcpChannel chan = new TcpChannel(1234); ChannelServices.RegisterChannel(chan, 4. IIOP .NET Questions Steven JABBOUR IR3 false); RemotingConfiguration.RegisterWellKnownS erviceType(type, url, modetransmission) Ecrire le client (HelloServant)Activator.GetObject(typeof(H elloServant), "tcp://localhost:1234/SayHello"); Compilation, déploiement et exécution Démonstration et test ☺ 13 Comparaison avec RMI Plan 1. Le Framework .NET 2. Services Web 3. .NET Remoting 4. IIOP .NET Tableau de synthèse Proxy (client) Squelettes (serveur) Objet distribué Configuration Annuaire Distribué Ajout de protocoles Ajout de formats Activation .NET Remoting Dynamique Intégré au framework Classes Fichier XML Aucun Channels Formatters SingleCall, Singleton CustomProxy Protocoles existants Gestion d’erreur Custom RealProxy HTTP, TCP, SOAP Exceptions Remote RMI Statique (rmic) ou dynamique Intégré au framework Interface Remote System Property RmiRegistry SocketFactoryImpl Serialization API coté serveur Activable Objects Dynamic Proxy JRMP, IIOP, T3 (WebLogic) … Exceptions Remote Plus simple que RMI dans la mise en œuvre. Absence de service de nommage, utilisation d'annuaires (LDAP) à travers l'API System.DirectoryServices Questions Steven JABBOUR IR3 14 Présentation de IIOP .NET P LDA Plan 1. Le Framework .NET 2. Services Web RMI Client IIOP Client HTTP Client EJB Container HTTP Engine JSP Servlet Servlet Container 3. .NET Remoting SQLC RDBMS JDB Message Queue JMS IIOP ??? J2EE Server ? IIOP.NET 4. IIOP .NET Questions S .NET App SOAP Client Steven JABBOUR IR3 HTTP Client IIS – HTTP Engine Component Component CLR Host ASMX ASPX CLR Platform Other Resource t or c e r .Di m e yst y ET ADO.N RDBMS MSMQMessage Queue SOAP Controls ASP.NET CORBA Server ??? Other Server Other Resource 15 Présentation de IIOP .NET Plan Web Services sans état, aucun support pour les références d'objets distants, SOAP et XML trop verbeux. 2. Services Web Utilisation d'un canal basé sur le protocole IIOP. 3. .NET Remoting IIOP.NET agit comme un ORB CORBA, converti les types .NET en type CORBA. RMI/IIOP et IIOP.NET implémentent les mêmes fonctionnalités de la norme CORBA D'autres projets existent tel que Remoting.Corba ou Janeva, mais pas libre ou pas d'outil de génération de la description IDL 1. Le Framework .NET 4. IIOP .NET Questions Steven JABBOUR IR3 16 Questions ? Plan 1. Le Framework .NET 2. Services Web 3. .NET Remoting 4. IIOP .NET Questions Steven JABBOUR IR3 17 Liens et références utiles Plan .NET Sites consacrés à .NET : 1. Le Framework .NET Framework: 2. Services Web ASP.NET La fameuse MSDN : Liens Steven JABBOUR http://msdn2.microsoft.com/fr-fr/default.aspx http://www.dotnetguru.org/articles/InteropWS/InteropWSJavaDotNet.htm http://www.dotnetguru.org/articles/webservices/WebServices.htm http://rangiroa.essi.fr/cours/travail-etudiant/01-castejon-corbucci-delattre-weber/jerome.htm http://www.microsoft.com/france/msdn/webservices/MiseEnRouteWebXml.mspx http://uddi.microsoft.com .Net Remoting Questions ASP.NET Etape par étape de G. Andrew Dutchie Web Services 4. IIOP .NET ASP.NET – Mono : http://www.mono-project.com/ASP.NET DotGNU Portable.NET: http://dotgnu.org/pnet.html Rotor : http://msdn.microsoft.com/msdnmag/issues/02/07/SharedSourceCLI/ http://www-igm.univ-mlv.fr/~dr/XPOSE2002/Dotnet/introdotnet_index.html http://www-igm.univ-mlv.fr/~dr/XPOSE2002/Tedeschi/ Linux: 3. .NET Remoting http://www.gotdotnet.com/ .NET 3.0 : http://www.microsoft.com/france/msdn/netframework/3/default.mspx http://wcf.netfx3.com/files/folders/distributed_applications/default.aspx http://www.dotnetguru.org/articles/CoucheService.htm http://www.dotnetguru.org/articles/RemotingRmi.htm http://www.dotnetguru.org/articles/Stateful/StateFul.htm http://www.dotnetguru.org/articles/perfs/PerfRemoting.htm http://www.dotnetguru.org/articles/CustomProxy.htm http://www.dotnetguru.org/articles/LDAP/LDAPDotNET.html Advanced .Net Remoting (Broché) de Ingo Rammer IIOP.NET et Remoting.CORBA http://iiop-net.sourceforge.net/ http://www.dotnetguru.org/articles/articlets/iiopchannel/iiopremoting.htm http://www.dotnetguru.org/articles/Reflexion/corbadotnet/CorbaDotNet.htm http://www.codeproject.com/csharp/dist_object_system.asp IR3 18