SlideServe
Menu
Préférences
© SlideServe · v2026

WCF 101

annot avatar
29 diapositives · 512 Views · Jul 30, 2014

WCF 101. Barry Dorrans http://idunno.org. About the Speaker (the ego slide). MVP – Visual Tools, Security barryd@idunno.org. Agenda What is WCF? The ABCs of WCF Defining a contract Hosting the service Handling Errors Logging. What is WCF?. Indigo

WCF 101 - slide 1
01 / 29WCF 101
1 / 17

Télécharger la présentation

WCF 101
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. WCF 101 Barry Dorrans http://idunno.org

  2. About the Speaker(the ego slide) MVP – Visual Tools, Security barryd@idunno.org

  3. Agenda What is WCF? The ABCs of WCF Defining a contract Hosting the service Handling Errors Logging

  4. What is WCF? Indigo Replaces Web Services, WSE & Remoting Interoperability

  5. The ABCs of WCF Address Binding Contract

  6. Client Server Messaging Layer Endpoint Service Model Address Binding Channel Behaviour Behaviour Contract Binding Binding Channel Behaviour Behaviour Factory Listener Channel Address Address Channel *

  7. Address scheme:// <machineName>[:port]/path http://localhost:8080/Account/ net.tcp://localhost:8080/Account

  8. Binding How you communicate with a service A service may have multiple bindings Defines the shape; security etc.

  9. Contract The external interface Contracts for service, data and message

  10. The ABCs Address = WHERE Binding = HOW Contract = WHAT

  11. Service Contracts [ServiceContract()] public interface IMyService { [OperationContract] string MyOperation1(string myValue); [OperationContract] string MyOperation2(MyDataContract value); }

  12. Data Contracts [DataContract] public class MyDataContract { string _stuff; [DataMember] public string Stuff { get { return _stuff; } set { stuff = value; } } }

  13. Creating our first WCF service

  14. So what have we learned? VS2008 gives us a test harness Service behaviour in config Barry can’t type under pressure.

  15. Why data contracts?

  16. Why data contracts? Message body or Message Header Control over the order of members Required versus optional parameters

  17. Version Tolerance

  18. So what have we learned? We need data contracts Why? – Version Tolerance WCF exposes nothing by default This is the opposite of XML Serialization

  19. Hosting the service

  20. So what have we learned? We can host in IIS or a .net program So we can use WCF for inter-process or inter-program communication

  21. Hosting in a program Create a new ServiceHost and Open using (ServiceHost host = new ServiceHost(typeof(MyService))) { host.Open(); ..... }

  22. Hosting in IIS Add a .svc file <%@ServiceHost Service="Namespace.ServiceType" %> <%@Assembly Name="AssemblyName" %>

  23. Replacing ASMX Double Decorate Contracts Watch the action & message names Remap ASMX to WCF Only use basicHttpBinding

  24. Gotcha! Registering addresses netsh http add urlaclurl=http://+:8080/echoService user=BUILTIN\Users

  25. Getting service information foreach (ServiceEndpoint endpoint in myServiceHost.Description.Endpoints) { Console.WriteLine("Endpoint - address: {0}", endpoint.Address); Console.WriteLine("- binding name:\t\t{0}", endpoint.Binding.Name); Console.WriteLine("- contract name:\t\t{0}", endpoint.Contract.Name); }

  26. Exceptions and errors.

  27. So what have we learned? Raw exceptions are not helpful Inner exceptions are still not good Contracted faults are the way to go

  28. Logging

  29. Questions?