1 / 40

ABCs of Windows Communication Foundation

ABCs of Windows Communication Foundation. Jeremy Sublett, MCSD, MCT Composable Systems Blog: http://JeremySublett.com. Agenda. Core Concepts Contracts Bindings Behaviors Real-World. Core Concepts. Unified Communications. WCF. ASMX. .NET Remoting. Enterprise Services. WSE.

lore
Download Presentation

ABCs of Windows Communication Foundation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ABCs of Windows Communication Foundation Jeremy Sublett, MCSD, MCT Composable Systems Blog: http://JeremySublett.com

  2. Agenda • Core Concepts • Contracts • Bindings • Behaviors • Real-World

  3. Core Concepts

  4. Unified Communications WCF ASMX .NET Remoting Enterprise Services WSE System.Messaging

  5. Standards • WS-Security • WS-Transactions • WS-ReliableMessaging • WS-MetadataExchange • WS-Policy • WS-Addressing • MTOM

  6. Message Message Service Communication Service 1 Service 2 Caller Service

  7. Endpoint Endpoint Endpoint Endpoints Caller Service Message

  8. C C C B B B A A A Address, Binding, Contract Caller Service Message Address Binding Contract (Where) (How) (What)

  9. C C C B B B A A A Metadata Metadata Caller Service Message

  10. C C C B B B A A A Behaviors Metadata Caller Service Bv Bv Message Bv Bv

  11. C C C B B B A A A Runtime Metadata Caller Service Bv Bv Message Bv Bv Proxy ServiceHost<T>()

  12. Demo 1: IIS

  13. Hosting Options • IIS • Self-Hosted (Any managed application) • Windows Service • Windows Activation Service (WAS)

  14. Contracts

  15. Contracts: Overview Describes the operations a service can perform. Maps CLR types to WSDL. Service Describes a data structure. Maps CLR types to XSD. Data Defines the structure of the message on the wire. Maps CLR types to SOAP messages. Message

  16. Service Contract [ServiceContract] public interface ICalculator { [OperationContract] ComplexProblem SolveProblem (ComplexProblem p); }

  17. Service Contract: OneWay [ServiceContract] public interface IOneWayCalculator { [OperationContract(IsOneWay=true)] void StoreProblem (ComplexProblem p); }

  18. Service Contract: Duplex [ServiceContract(CallbackContract= typeof(ICalculatorResults)] public interface ICalculatorProblems { [OperationContract(IsOneWay=true)] void SolveProblem (ComplexProblem p); } public interface ICalculatorResults { [OperationContract(IsOneWay=true)] void Results(ComplexProblem p); }

  19. Service Contract: Faults [ServiceContract(Session=true)] public interface ICalculator { [OperationContract] [FaultContract(typeof(DivideByZeroException))] ComplexProblem SolveProblem (ComplexProblem p); } try { return n1 / n2; } catch (DivideByZeroException e){ DivideByZeroException f = new DivideByZeroException (“Calc Failure”); throw new FaultException<DivideByZeroException>(f); }

  20. Data Contract [DataContract] public class ComplexNumber { [DataMember] public double Real = 0.0D;[DataMember] public double Imaginary = 0.0D; public ComplexNumber(double r, double i) { this.Real = r; this.Imaginary = i; } }

  21. Message Contract [MessageContract] public class ComplexProblem { [MessageHeader] public string operation; [MessageBody]public ComplexNumber n1; [MessageBody]public ComplexNumber n2; [MessageBody]public ComplexNumber solution; // Constructors… }

  22. Bindings

  23. HTTP Text WS-* WS-* WS-* TCP Binary HTTP Text TCP Binary WS-* WS-* WS-* Elements of Binding Transport Encoder Security Reliability Protocol Pipes MTOM Custom Custom Custom MSMQ Custom Custom

  24. Standard Bindings Interop Security Session Transx Duplex Stream T = Transport Security | S = WS-Security | O = One-Way Only BasicHttpBinding BP T WsHttpBinding WS TS WsDualHttpBinding WS TS NetTcpBinding TS O NetNamedPipesBinding TS O NetMsmqBinding TS NetPeerTcpBinding TS

  25. Interop With Existing Technologies ASMX/WSE3 WCF WS-* Protocols Moniker COM+/ES WCF WS-* Protocols Moniker MSMQ WCF MSMQ Protocol

  26. Binding in Config <?xml version="1.0" encoding="utf-8" ?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.serviceModel> <services> <service type="CalculatorService"> <endpoint address=“http://localhost/calculator" binding="basicHttpBinding" contractType="ICalculator" /> </service> </services> </system.serviceModel> </configuration>

  27. Configuring Bindings <endpoint address=“http://localhost/calculator" binding="basicHttpBinding" bindingConfiguration="Binding1" contractType="ICalculator" /> <bindings> <basicHttpBinding> <binding configurationName="Binding1" hostNameComparisonMode="StrongWildcard"sendTimeout="00:10:00" maxMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" </binding></basicHttpBinding></bindings>

  28. Demo 2: Binding Configuration

  29. Custom Bindings <bindings> <customBinding> <binding configurationName="Binding1"> <reliableSession bufferedMessagesQuota="32" inactivityTimeout="00:10:00" maxRetryCount="8"ordered="true" /> <httpsTransport manualAddressing="false" maxMessageSize="65536" hostNameComparisonMode="StrongWildcard"/> <textMessageEncoding maxReadPoolSize="64"maxWritePoolSize="16"messageVersion="Default" writeEncoding="utf-8" /> </binding> </customBinding> </bindings>

  30. Behaviors

  31. Behaviors: Overview • Behaviors are about system semantics • Developers care about some behaviors • Concurrency • Instancing • Transactions • Impersonation • Deployers care about other behaviors • Throttling • Metadata exposure

  32. Instancing • Single • Per call • Per Session

  33. Instancing in Code [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] public class Calculator : ICalculator{ public ComplexProblemSolveProblem (ComplexProblem p) { switch (p.operation) { case "Add": p.solution.Real = p.n1.Real + p.n2.Real; p.solution.Imaginary = p.n1.Imaginary + p.n2.Imaginary; return p; break; // … } }}

  34. Throttling <service type="Calculator" behaviorConfiguration="CalculatorBehavior"> <!-- endpoint definitions /--> </service> <behaviors> <behavior configurationName="CalculatorBehavior"> <serviceThrottling maxConcurrentCalls="10" maxConnections="10" maxInstances="10" maxPendingOperations="10" /> </behavior> </behaviors>

  35. Real-World

  36. Business Scenario • Intranet-based service • Enterprise-focused (used by many internal applications) • Long-running operations – 5+ minutes • Non-WCF clients

  37. Architecture BizTalk Postal Address Service basicHttpBinding WCF EndPoint Workflow ASMX Proprietary TCP External Data Sources Proprietary Postal Service

  38. Demo 3: Real-World

  39. Summary • Broad range of functionality for building distributed applications • Fundamental concepts are enough to start • Standards-based • Foundational for service-oriented designs

  40. Questions? http://ComposableSystems.NET Blog: http://JeremySublett.com

More Related