[Title of the course] WCF

Slides:



Advertisements
Similar presentations
18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
Advertisements

Michael S. Chan xLM Solutions, LLC
Siebel Web Services Siebel Web Services March, From
WCF Intro Scott Reed Owner - Brain Hz Software Instructor – DevelopMentor
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
General introduction to Web services and an implementation example
SOAP.
RPC Robert Grimm New York University Remote Procedure Calls.
Web Services Darshan R. Kapadia Gregor von Laszewski 1http://grid.rit.edu.
Web Services Nasrullah. Motivation about web service There are number of programms over the internet that need to communicate with other programms over.
SOAP Quang Vinh Pham Simon De Baets Université Libre de Bruxelles1.
Zoiner Tejada Hershey Technologies. About Zoiner Tejada.
 Introduction  WCF Definition  WCF Architecture  Implementation  WCF Demo Overview.
Presentation 7 part 2: SOAP & WSDL. Ingeniørhøjskolen i Århus Slide 2 Outline Building blocks in Web Services SOA SOAP WSDL (UDDI)
Windows Communication Foundation and Web Services.
6/11/2015Page 1 Web Services-based Distributed System B. Ramamurthy.
The Microsoft Technical Roadshow 2006 Windows Communication Foundation Mike Taulty Developer & Platform Group Microsoft Ltd
Module 13: WCF Receive Adapters. Overview Lesson 1: Introduction to WCF Receive Adapters Lesson 2: Configuring a WCF Receive Adapter Lesson 3: Using the.
Getting Started with Windows Communication Foundation 4.5 Ed Jones, MCT, MCPD, MCTS Consultant RBA Inc.
Getting Started with WCF Windows Communication Foundation 4.0 Development Chapter 1.
Processing of structured documents Spring 2003, Part 6 Helena Ahonen-Myka.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Introduction to Windows Communication Foundation Ruwan Wijesinghe.
Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services.
C Copyright © 2009, Oracle. All rights reserved. Appendix C: Service-Oriented Architectures.
Grid Computing, B. Wilkinson, 20043b.1 Web Services Part II.
1 Windows Communication Foundation: Integrating COM+ and MSMQ Applications Andy Milligan COM305 Program Manager Microsoft Corporation.
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
Enabling Embedded Systems to access Internet Resources.
Web Services & WCF ~ Ankit. Web services A web service is a collection of protocols and standards used for exchanging data between applications or systems.
CSCI 6962: Server-side Design and Programming Web Services.
James Holladay, Mario Sweeney, Vu Tran. Web Services Presentation Web Services Theory James Holladay Tools – Visual Studio Vu Tran Tools – Net Beans Mario.
Lecture 15 Introduction to Web Services Web Service Applications.
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Web Services Based on SOA: Concepts, Technology, Design by Thomas Erl MIS 181.9: Service Oriented Architecture 2 nd Semester,
XML Web Services Architecture Siddharth Ruchandani CS 6362 – SW Architecture & Design Summer /11/05.
Web Services. ASP.NET Web Services  Goals of ASP.NET Web services:  To enable cross-platform, cross- business computing  Great for “service” based.
Random Logic l Forum.NET l Web Services Enhancements for Microsoft.NET (WSE) Forum.NET ● October 4th, 2006.
Mahesh Krishnan, Senior Consultant, Readify Slide 1.
Chapter 10 Intro to SOAP and WSDL. Objectives By study in the chapter, you will be able to: Describe what is SOAP Exam the rules for creating a SOAP document.
Telerik Software Academy Web Services & Cloud.
Copyright © 2013 Curt Hill SOAP Protocol for exchanging data and Enabling Web Services.
1 Web Services Web and Database Management System.
INT-9: Implementing ESB Processes with OpenEdge ® and Sonic ™ David Cleary Principal Software Engineer.
Web Services Error Handling and Debugging. Agenda Simple SOAP faults Advanced SOAP faults SOAP headers and faults Error handling From a Service Perspective.
Kemal Baykal Rasim Ismayilov
ASP.NET Web Services.  A unit of managed code installed under IIS that can be remotely invoked using HTTP.
Windows Communication Foundation David Anderson Independent Software Developer DCOM Productions.
Chapter 7: Creating and Consuming XML Web Services Understanding XML Web Services Creating XML Web Services Deploying and Discovering XML Web Services.
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
Presentation 24: Windows Communication Foundation Introduced Objektorienteret Netværkskommunikation.
Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services.
.NET Mobile Application Development XML Web Services.
Introduction to Web Services Presented by Sarath Chandra Dorbala.
Dhananjay Kumar MVP-Connected System 1. WCF  Agenda What is WCF ? Why WCF? Address, Binding, Contract End Points Hosting Message Patterns Programming.
1 G52IWS: Web Services Description Language (WSDL) Chris Greenhalgh
Net-centric Computing Web Services. Lecture Outline  What is Web Service  Web Service Architecture  Creating and using Java Web Services  Apache Axis.
OE-NIK HP Advanced Programming WCF WCF SOAP service, host, client Exception handling (NOT required)
OE-NIK HP Advanced Programming Web services Standards and protocols Using web services Using web services with asynchronous calls.
Software Architecture Patterns (3) Service Oriented & Web Oriented Architecture source: microsoft.
O VERVIEW OF SOA AND WCF Jinaldesai.net – My Thouths And Learnings.
Windows Communication Foundation and Web Services
Jim Fawcett CSE681 – SW Modeling & Analysis Spring 2005
Configuring and Hosting WCF Services
Sabri Kızanlık Ural Emekçi
Distribution of functionality Webservice using WCF
Windows Communication Foundation and Web Services
Distributed System using Web Services
WEB SERVICES From Chapter 19, Distributed Systems
Distributed System using Web Services
Presentation transcript:

[Title of the course] WCF 20-Apr-17 [Title of the course] WCF WCF www.supinfo.com Copyright © SUPINFO. All rights reserved Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Course Objectives After this course, you will be able to: 20-Apr-17 Services [Title of the course] Course Objectives After this course, you will be able to: Understand how do Services work. Presentation, protocol and format. Create and consume a Service in .NET. Creating, deploying and consuming them. Optimize Services. By using cache, sessions… Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Course Topics This course is divided into the following sections: 20-Apr-17 Services [Title of the course] Course Topics This course is divided into the following sections: Introduction. Protocol and formats used in Services. Services in .NET. Creating, deploying and consuming Services in .NET. Optimizing Services. By using cache, sessions… Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

[Title of the course] Introduction, protocol and format of services… 20-Apr-17 [Title of the course] Services Service Basics Introduction, protocol and format of services… Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Section Topics We are going to walk through the following chapters: 20-Apr-17 Service Basics [Title of the course] Section Topics We are going to walk through the following chapters: Introduction to Services SOAP Protocol WSDL Format UDDI Directory Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Introduction to Services 20-Apr-17 Service Basics [Title of the course] Introduction to Services A Service is a group of protocols and computer standards, used for exchanging data between applications. — Wikipedia, Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Introduction to Services 20-Apr-17 Service Basics [Title of the course] Introduction to Services SOA : Services Oriented Architecture OOP complement Used in processing and communicating with Services. Objectives Productive Reactive Capable of managing responsibility On peut citer la SNCF, qui a mis en place une architecture de type SOA pour son système de réservation (recherche d'horaire, demande de tarif, réservation...) qui prend en charge à la fois les terminaux des guichets des agences et gares, et les sollicitations de son site web de commande en ligne Les architectures SOA reposent principalement sur l’utilisation d’interface d’invocation (SOAP) et de vocabulaire de description de données (WSDL et XML) qui doivent être communs à l’ensemble des agents (fournisseurs de services et utilisateurs de services). la notion de SOA (pour architecture orientée services) définie un modèle d'interaction applicative mettant en oeuvre des connexions en couplage lâche entre divers composants logiciels (ou agents). Ici, on entend par "service" une action exécutée par un composant "fournisseur" à l'attention d'un composant "consommateur", basé éventuellement sur un autre système. Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Introduction to Services 20-Apr-17 Service Basics [Title of the course] Introduction to Services SOA : Services Oriented Architecture Based on 4 principals: The borders are explicit. The services are independent of one another. Contracts are shared, but not objects. Semantics are dictated by rules. Les frontières d’un service sont explicites : Le client et le développeur sont conscients que l’appel aux méthodes distantes se fait à travers des messages et passent par le réseau. Cela permet par exemple d’utiliser d’autres méthodes que la classique demande/réponse synchrone qui est utilisée pour simuler l’appel à une méthode locale. Les services sont indépendants : Un service est autonome, et donc ce sont les clients qui doivent s’adapter lors de l’évolution d’un service à une nouvelle version. L’avantage est qu’ainsi l’interaction entre plusieurs services se fait naturellement et les services s’adaptent entre eux aux nouvelles contraintes. Il est donc important pour le service de gérer les erreurs, surtout pour les clients qui ne seraient pas à jour. L’utilisation d’un service est décrite à l’aide d’un contrat : Le contrat est un représenté par un fichier XML. Il contient entre autres la structure des informations contenues dans les messages entrant et sortant. Ce contrat peut contenir de commentaires. Le contrat est souvent utilisé pour définir la construction des classes du client. La sémantique est dictée par des règles : La sémantique, le format des messages et la stratégie d’accès au service peuvent être spécifiés (si nécessaire) dans le contrat par des règles. Ainsi, un service peut définir qu’il n’accepte que les messages entrants encryptés d’une certaine façon, ou encore qu’il n’est accessible que dans une tranche horaire définie, etc. La définition de cette sémantique peut être consommée par un framework, pour que l’encryptage des données se fasse automatiquement sans intervention du développeur du client, par exemple. Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Introduction to Services 20-Apr-17 Service Basics [Title of the course] Introduction to Services A service and clients communicates by messages. A client sends a request, the server sends back a response. Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Introduction to Services 20-Apr-17 Service Basics [Title of the course] Introduction to Services Advantages and disadvantages of Services Advantages: Interoperability Simplified access Accessible data exchange format Centralized arrangement Disadvantages: Poor performance Ever-changing standards Avantages : Interopérabilité : Un service web développé en .Net pourra être consommé en Perl, en Java, en PHP… Accès simplifié : L’utilisation d’HTTP comme protocole d’accès aux services web évite les problèmes liés à l’utilisation de firewalls Format d’échange accessible : Les échanges entre le client et le service web est au format texte, ce qui facilite la compréhension et l’exploitation Mise à disposition centralisée : Services permettent de mettre à disposition à un seul endroit un composant utilisé en interne ou de le fournir à des prestataires ou des clients Inconvénients : Services ne sont pas performants : L’utilisation de format texte, des standards du web et la compatibilité entre plate formes sont à ce prix Une technologie en perpétuelle évolution : Les normes et les fonctionnalités ne cessent d’évoluer Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

20-Apr-17 Service Basics [Title of the course] SOAP Protocol Allows the transmission of structured and formatted data in messages between 2 distant objects. Standard defined by W3C Based on XML Current version: 1.2 Il permet la transmission de messages entre objets distants, ce qui veut dire qu'il autorise un objet à invoquer des méthodes d'objets physiquement situés sur une autre machine. Le transfert se fait le plus souvent à l'aide du protocole HTTP, mais peut également se faire par un autre protocole, comme SMTP. Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

SOAP Protocol Composition of a message Envelope: 20-Apr-17 Service Basics [Title of the course] SOAP Protocol Composition of a message Envelope: is the root element of SOAP message. contains no or several attributes. contains Header (optional) Body (mandatory) Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

SOAP Protocol Composition of a message Service Basics Header : 20-Apr-17 Service Basics [Title of the course] SOAP Protocol Composition of a message Header : Optional Used for adding complementary information to the message Contains arguments: actor, mustUnderstand… Body : Contains data of the message Corresponds to the XML Schemas specified in the service contract. Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

SOAP Protocol Example of a SOAP message Service Basics 20-Apr-17 Service Basics [Title of the course] SOAP Protocol Example of a SOAP message <soap:Envelope xmlns:"http://schemas.xmlsoap.org/soap/envelope"/> <soap:Header> </soap:Header> <soap:Body> </soap:Body> </soap:Envelope> Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

20-Apr-17 Service Basics [Title of the course] WSDL Format WSDL defines, in an abstract and independent way, a group of operations and messages which can be transmitted to and from a given Service. — JDNet Developers, Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

WSDL Format Service Description Language 20-Apr-17 Service Basics [Title of the course] WSDL Format Service Description Language Description language of Services in XML format Used to draft a Service: describing functionalities “how” “where” Current version: 2.0 Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

WSDL Format Services Basics Le format wsdl sert a décrire un Service : 20-Apr-17 Services Basics [Title of the course] WSDL Format Le format wsdl sert a décrire un Service : Comment on communique avec ? Ou il se trouve ? Quelles opérations on peut faire avec ? Avec quelles données ? Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

WSDL Format WSDL skeleton Service Basics <definition> 20-Apr-17 Service Basics [Title of the course] WSDL Format WSDL skeleton <definition> <type /> <message> <operation> <message /> </operation> <portType> <operation/> </portType> <binding> </binding> <service> <port> <binding/> </port> </service> </definition> Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

UDDI Directory What is it? 20-Apr-17 Service Basics [Title of the course] UDDI Directory What is it? Universal Description, Discovery and Integration It is a directory of Services. which is a Service itself. It contains information on service providers (contracts, activities…) description on services (as part of the WSDL contract) Une fois qu'un Services est développé, il faut publier sa description et faire un lien vers elle dans un catalogue UDDI (Universal Description, Discovery and Integration), de sorte que les utilisateurs potentiels puissent le trouver. Quand un utilisateurs souhaite utiliser le service, il fait une demande de son fichier WSDL afin de connaître son emplacement, les appels de fonctions et comment y accéder. A partir de cela, il peut composer, par exemple, une requête SOAP (Simple Object Access Protocol) vers l'ordinateur du service. Tout ce parcours peut évidemment être automatisé à l'aide d'outils reconnaissant WSDL, et permet ainsi d'intégrer de nouveaux services pratiquement sans devoir entrer de nouveau code. Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

UDDI Directory How does it work? Service Basics 20-Apr-17 Service Basics [Title of the course] UDDI Directory How does it work? 1. I am looking for a Service… 2. Tell you how to connect to it. 3. What is the format for messages? 5. I send my SOAP requests. 4. Here is my WSDL contract. 6. Result for the SOAP request. Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Do you have any questions? 20-Apr-17 Service Basics [Title of the course] Stop-and-Think Do you have any questions? Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Services in .NET Creating, deploying and consuming Services in .NET. 20-Apr-17 [Title of the course] Services Services in .NET Creating, deploying and consuming Services in .NET. Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

In .NET you can use: WCF WCF RIA Services WCF Data Services Course 6461A Introduction Module 1: Getting Started with Windows Communication Foundation In .NET you can use: WCF WCF RIA Services WCF Data Services Expliquer la dif entre les trois. Parler que Data Service se met derrière une DAL directement (pas même architecture). Parler que RIA peut être vu comme un complément plutôt qu’un concurrent. WCF reste le plus utilisé et celui qui nous donne la possibilité de tout faire 23

WCF and SOA WCF supports SOA: Course 6461A Introduction Module 1: Getting Started with Windows Communication Foundation WCF and SOA WCF supports SOA: Most developers do not have to learn WSDL Lots of functionality is handled by the runtime Tools to enable easy creation and consumption of services However: Just because you have exposed an interface over a Web service protocol stack does not mean that you have created part of an SOA WCF plays the role of distribution mechanism, while SOA comes in at a higher level 24

Preview Section plan: Service-Oriented Development with WCF Course 6461A WCF Basics Module 1: Getting Started with Windows Communication Foundation Preview Section plan: Service-Oriented Development with WCF Sending a WCF Message The ABC of Endpoints Structure of a Service A Unified Programming Model Communicating with Non-WCF Services 25

Module 1: Getting Started with Windows Communication Foundation Course 6461A WCF Basics Module 1: Getting Started with Windows Communication Foundation A Unified Programming Model Many confusing and complicated options Remoting COM DCOM COM+ MSMQ WSE ASMX A unified development model Windows Communication Foundation

Service-Oriented Development with WCF Course 6461A WCF Basics Module 1: Getting Started with Windows Communication Foundation Service-Oriented Development with WCF Create a service: Over a network protocol Use a service: Contact the service to access one part of that functionality Clients and services communicate by passing messages Not limited to one particular set of protocols Aimed at clients and services that do not share the same address space Service-oriented architecture is a bigger concept related to the style of the application and granularity of the services 27

A B C The ABC of endpoints Address WCF Basics Course 6461A WCF Basics Module 1: Getting Started with Windows Communication Foundation The ABC of endpoints Where to find the service Example: http://localhost:8001/MathService Address A Service How to communicate with the service Example: BasicHttpBinding Binding B What the service can do for you Example: [OperationContract] int Add(int num1, int num2); Contract C 28

Module 1: Getting Started with Windows Communication Foundation Course 6461A WCF Basics Module 1: Getting Started with Windows Communication Foundation Sending a WCF message WCF dispatcher Client Proxy Service Endpoints Binding Channel Channel Encoding Message Encoding Transport channel Transport channel

Module 1: Getting Started with Windows Communication Foundation Course 6461A WCF Basics Module 1: Getting Started with Windows Communication Foundation Structure of a service .NET Classes and Interface Service Service Host Service Contracts for Domain Functionality or Metadata Exchange

Do you have any questions ? 20-Apr-17 WCF Basics [Title of the course] Stop-and-think Do you have any questions ? Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Defining a service contract 20-Apr-17 [Title of the course] Windows Communication Foundation Defining a service contract Using a Language-Level Interface as a Service Contract Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Module 1: Getting Started with Windows Communication Foundation Course 6461A Defining a service contract Module 1: Getting Started with Windows Communication Foundation Preview Section plan: Example of a Simple Contract The ServiceContract Attribute The OperationContract Attribute Data and Messages Defining a data contract

Module 1: Getting Started with Windows Communication Foundation Course 6461A Defining a service contract Module 1: Getting Started with Windows Communication Foundation Example of a Simple Contract using System; using System.ServiceModel; namespace ServiceContracts { [ServiceContract(Namespace="http://myuri.org/Hello") ] public interface IService [OperationContract] HelloMessage GetHelloMessage(string name); } Principal namespace for WCF Attributes control exposure of types and methods

Module 1: Getting Started with Windows Communication Foundation Course 6461A Defining a service contract Module 1: Getting Started with Windows Communication Foundation The ServiceContract attribute The ServiceContract attribute: Can be used on interfaces or classes Is identified by tools and environments that understand WCF Service contracts: Support services Are analogous to interfaces on a polymorphic object – caller may not know or care about other contracts Are only visible to clients if exported on an endpoint Contains one or more operations

Module 1: Getting Started with Windows Communication Foundation Course 6461A Defining a service contract Module 1: Getting Started with Windows Communication Foundation The ServiceContract attribute Namespace serves to disambiguate types and operations in service metadata Defaults to http://tempuri.org Not to be confused with language-level namespace

Module 1: Getting Started with Windows Communication Foundation Course 6461A Defining a service contract Module 1: Getting Started with Windows Communication Foundation The OperationContract Attribute The OperationContract Attribute: Attribute can be used on methods but not other class elements, such as properties or indexers Identified by tools and environments that understand WCF Methods are only visible in service contract if marked with OperationContract

Module 1: Getting Started with Windows Communication Foundation Course 6461A Defining a service contract Module 1: Getting Started with Windows Communication Foundation Data and messages Parameters and return values must be marshaled between client and server CLR types are mapped to XML Infoset by serialization WCF enables you to define custom serialization Serialized data is packed into the message Contents and structure of message must be understood by client or service at the other end Data and message contracts provide control over these areas

Module 1: Getting Started with Windows Communication Foundation Course 6461A Defining a service contract Module 1: Getting Started with Windows Communication Foundation Defining a data contract using System; using System.Runtime.Serialization; namespace DataContracts { [DataContract] public class HelloMessage private string _content; [DataMember] public string Content get { return _content; } set { this._content = value;} }

Module 1: Getting Started with Windows Communication Foundation Course 6461A Defining a service contract Module 1: Getting Started with Windows Communication Foundation Implementing a service contract Define a class implementing the service contract using System; using ServiceContracts; using DataContracts; namespace ServiceImplementation { public class HelloService : IService public HelloMessage GetMessage(string name) // Write implementation code here }

Do you have any questions ? 20-Apr-17 Defining a service contract [Title of the course] Stop-and-think Do you have any questions ? Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Service contracts and implementation 20-Apr-17 Defining a service contract [Title of the course] Demonstration Service contracts and implementation Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Hosting and Consuming a WCF Service 20-Apr-17 [Title of the course] Windows Communication Foundation Hosting and Consuming a WCF Service Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Preview Separation of Concerns in a WCF Service Course 6461A Hosting and Consuming a WCF Service Module 2: Configuring and Hosting WCF Services Preview Separation of Concerns in a WCF Service Life Cycle of a Self-Hosted WCF Service Consuming a WCF Service Configuring a WCF Service Host and a client Generating artifacts from service metadata

Separation of Concerns in a WCF Service Course 6461A Hosting and Consuming a WCF Service Module 2: Configuring and Hosting WCF Services Separation of Concerns in a WCF Service WCF solution WCF Service Library Contract Implementation WCF Service Host Configuration Host code

Life Cycle of a Self-Hosted WCF Service 20-Apr-17 Hosting and Consuming a WCF Service [Title of the course] Life Cycle of a Self-Hosted WCF Service Using the namespace System.ServiceModel Instantiate a Service Host object System.ServiceModel.ServiceHost Add a service endpoint with : Contract Binding Address Open the ServiceHost to start listening 1 2 3 Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Life Cycle of a Self-Hosted WCF Service 20-Apr-17 Hosting and Consuming a WCF Service [Title of the course] Life Cycle of a Self-Hosted WCF Service Prevent the ServiceHost from closing (i.e Console.ReadLine() Close and dispose of the ServiceHost object 4 5 ServiceHost Service type Address Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

20-Apr-17 Hosting and Consuming a WCF Service [Title of the course] Calling a WCF Service To call a WCF service, the client needs the following: A channel over which to pass messages Transport channel at the bottom The makeup of the channel derives from the binding A client-side representation of the contract Referencing the service contracts assembly Generating artifacts from metadata A way of creating WCF messages to pass across the channel and a way of retrieving message contents An address for the WCF service Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Module 1: Getting Started with Windows Communication Foundation Course 6461A Hosting and Consuming a WCF Service Module 1: Getting Started with Windows Communication Foundation Contracts, metadata and artifacts Running Service Implements Service Assembly Service Class Service Metadata Generate Generate Service Interface Generate Service Proxy ServiceModel Metadata Utility Tool (Svcutil.exe) generates metadata and artifacts Proxy Artifacts Implements

Consuming a service (1) Using the ChannelFactory class 20-Apr-17 Hosting and Consuming a WCF Service [Title of the course] Consuming a service (1) Using the ChannelFactory class Reference the Service Contracts assembly Instantiate a typed Channel Factory with the binding and the address of the service System.ServiceModel.ChannelFactory<T> T represents the type of the contract Call the CreateChannel() method to contact the service and create a proxy Start calling the methods… 1 2 3 4 Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

« First WCF Demo » Demonstration Hosting and Consuming a WCF Service 20-Apr-17 Hosting and Consuming a WCF Service [Title of the course] Demonstration « First WCF Demo » Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

File-based configuration Course 6461A Hosting and Consuming a WCF Service Module 2: Configuring and Hosting WCF Services File-based configuration File-based configuration You can use app.config, web.config, and machine.config files You can change the WCF configuration without recompiling the assembly Programmatic configuration Provides greater control of your WCF configuration Takes precedence over file-based configuration

Identifying WCF Entries in Configuration Files Course 6461A Hosting and Consuming a WCF Service Module 2: Configuring and Hosting WCF Services Identifying WCF Entries in Configuration Files Host configuration file <system.serviceModel> <services> <service name=”ServiceImplementation.HelloService"> <endpoint address="http://localhost:1664/HelloService" binding="basicHttpBinding" contract="ServiceContract.IService"/> </service> </services> </system.serviceModel> Client configuration file <system.serviceModel> <client> <endpoint name="tcpEndpoint" address="http://localhost:1664/HelloService" binding="basicHttpBinding" contract="ServiceContract.IService"/> </client> </system.serviceModel>

« Configuration » Demonstration Hosting and Consuming a WCF Service 20-Apr-17 Hosting and Consuming a WCF Service [Title of the course] Demonstration « Configuration » Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Obtaining Service Information Course 6461A Hosting and Consuming a WCF Service Module 2: Configuring and Hosting WCF Services Obtaining Service Information Obtain information from service metadata and generate artifacts WCF Service WCF types MEX endpoint Artifacts Obtain information and artifacts manually from service provider

20-Apr-17 Hosting and Consuming a WCF Service [Title of the course] Consuming a service (2) Using generated artifacts – Mex (Metadata Exchange) Add a reference to the service (“Add Service Reference”) The tool Svcutil.exe generates code from the metadata of the service: Proxy classes and interface Instantiate a proxy service class object Start calling the methods… 1 2 3 Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

« Mex » Demonstration Hosting and Consuming a WCF Service 20-Apr-17 [Title of the course] Demonstration « Mex » Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Solutions to host a WCF Service 20-Apr-17 [Title of the course] Windows Communication Foundation Solutions to host a WCF Service Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Preview Hosting a service in a self-managed Application Course 6461A Solutions to host a WCF Service Module 2: Configuring and Hosting WCF Services Preview Hosting a service in a self-managed Application Hosting a service in a Windows Service Hosting a service in IIS Hosting a service in WAS

Hosting a service Host environment Solutions to host a WCF Service 20-Apr-17 Solutions to host a WCF Service [Title of the course] Hosting a service Host environment Typical functionality: Reads and understands WCF configuration settings Creates endpoints and listens for requests from remote clients Routes requests to an appropriate service instance Creates and destroys service instances Additional functionality: Isolate different service instances from each other Serialize and re-activate unused service instances Manage pre-created pools of service instances Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Service Hosting Options 20-Apr-17 Solutions to host a WCF Service [Title of the course] Service Hosting Options Self-hosted managed application IIS WAS IIS and WAS offer the following improved hosting features: Message-based activation Process recycling Idle shutdown Process health monitoring Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Hosting a WCF Service in a Self-Hosted Managed Application Course 6461A Solutions to host a WCF Service Module 2: Configuring and Hosting WCF Services Hosting a WCF Service in a Self-Hosted Managed Application Windows Forms application Windows service Windows Console application WPF application

Implementing a Self-Hosted Service 20-Apr-17 Solutions to host a WCF Service [Title of the course] Implementing a Self-Hosted Service Manually activated by starting process Need to write your own hosting code WCF configuration in the app.config file Expose your WCF service over any protocol Self-hosted service application Service host code WCF configuration Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Hosting in a Windows Service 20-Apr-17 Solutions to host a WCF Service [Title of the course] Hosting in a Windows Service Easily auto-started on startup Manage process life cycle in the management console snap-in Subclass ServiceBase and override OnStart and OnStop protected override void OnStart(string[] args) { //Instantiate the ServiceHost... } protected override void OnStop() // Close the ServiceHost... Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

« Windows Service Deployment » 20-Apr-17 Solutions to host a WCF Service [Title of the course] Demonstration « Windows Service Deployment » Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Implementing an IIS-Hosted Service 20-Apr-17 Solutions to host a WCF Service [Title of the course] Implementing an IIS-Hosted Service Instances activated when messages arrive No hosting code required from service developer WCF configuration in web.config file Limited to HTTP protocol Need service file (.svc) containing ServiceHost directive to link IIS to service class <%@ServiceHost Service="ServiceImplementation.HelloService"%> In its simplest form, you can store the service classes in the App_Code sub directory Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

« IIS Deployment » Demonstration Solutions to host a WCF Service 20-Apr-17 Solutions to host a WCF Service [Title of the course] Demonstration « IIS Deployment » Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Implementing a WAS-Hosted Service 20-Apr-17 Solutions to host a WCF Service [Title of the course] Implementing a WAS-Hosted Service No hosting code required from service developer WCF configuration in web.config file Not limited to the HTTP protocol Need service file (.svc) containing ServiceHost directive to link IIS to service class <%@ServiceHost Service="ServiceImplementation.HelloService"%> Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

20-Apr-17 Solutions to host a WCF Service [Title of the course] Configuring WAS Enable “WCF Non-Http Activation Components” Windows components Bind desired Web site (usually default) to a non-HTTP port to support non-HTTP-based activation appcmd set site "Default Web Site"-+bindings.[protocol='net.tcp',bindingInformation='9000:*'] appcmd set app "Default Web Site/BankService“ /enabledProtocols:http,net.tcp,net.pipe Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

Preparing Services for Deployment Course 6461A Solutions to host a WCF Service Module 2: Configuring and Hosting WCF Services Preparing Services for Deployment Ultimately the service must leave the development environment Deployment mechanism and process depends on type of service host

Deploying IIS-Hosted Services Course 6461A Solutions to host a WCF Service Module 2: Configuring and Hosting WCF Services Deploying IIS-Hosted Services Compile code Install correct runtime Check endpoint addresses Disable debugging

+ Deploying WAS-Hosted Services Solutions to host a WCF Service Course 6461A Solutions to host a WCF Service Module 2: Configuring and Hosting WCF Services Deploying WAS-Hosted Services Install correct runtime + Perform WAS setup: Install components Configure non-HTTP activation Check endpoint addresses Disable debugging Compile code

Deploying Self-Hosted Services Course 6461A Solutions to host a WCF Service Module 2: Configuring and Hosting WCF Services Deploying Self-Hosted Services Create a Windows Installer (MSI) for the classes Register your Windows Service at installation time by using ServiceProcessInstaller and ServiceInstaller [RunInstaller(true)] public class ProjectInstaller : Installer { private ServiceProcessInstaller process; private ServiceInstaller service; public ProjectInstaller() process = new ServiceProcessInstaller(); process.Account = ServiceAccount.LocalSystem; service = new ServiceInstaller(); service.ServiceName =  "HelloService"; Installers.Add(process); Installers.Add(service); }

Do you have any questions? 20-Apr-17 Services [Title of the course] Stop-and-Think Do you have any questions? Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

For more… If you want to go into the topic more deeply, 20-Apr-17 Services [Title of the course] For more… If you want to go into the topic more deeply, Books Courses ASP.NET 2.0 Basics Security and Customization of Web Applications www.fnac.com Websites http://www.asp.net http://www.dotnetguru.org http://stephaneey.developpez.com/tutoriel/dotnet/webservice/ Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.

You have successfully completed 20-Apr-17 [Title of the course] Congratulations You have successfully completed Module 4 Services Copyright © 2004-2005 NameOfTheOrganization. All rights reserved. 76

End Adopt Services for your distributed applications! 20-Apr-17 Services [Title of the course] End Adopt Services for your distributed applications! You have finished the modules ASP.NET 2.0 and Services! Copyright © 2004-2005 NameOfTheOrganization. All rights reserved.