1 / 36

Windows Communication Foundation (WCF)

Windows Communication Foundation (WCF). Dhananjay Kumar MVP-Connected System. WCF. Agenda What is WCF ? Why WCF? Address , Binding, Contract End Points Hosting Message Patterns Programming Model Basic Task Cycle. From Objects to Services. Object-Oriented. Polymorphism

giles
Download Presentation

Windows Communication Foundation (WCF)

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. Windows Communication Foundation(WCF) Dhananjay Kumar MVP-Connected System

  2. WCF • Agenda • What is WCF ? • Why WCF? • Address , Binding, Contract • End Points • Hosting • Message Patterns • Programming Model • Basic Task Cycle

  3. From Objects to Services Object-Oriented Polymorphism Encapsulation Subclassing 1980s Component-Based Interface-based Dynamic Loading Runtime Metadata 1990s Service-Oriented Message-based Schema+Contract Binding via Policy 2000s

  4. The Four Tenets of Service-Orientation Boundaries are Explicit Developers opt-in to consuming, exposing, and defining public-facing service façade. Services and consumers are independently versioned, deployed, operated, and secured. Autonomous Evolution Data never includes behavior; Objects with data and behavior are a local phenomenon. Share schema & contract, not class Compatibility based on policy Capabilities and requirements represented by a unique public name; Used to establish service suitability.

  5. Benefits of Service Orientation Facilitates implementation/platform interop Independent deployment, versioning, mgmt Promotes technology reuse

  6. The Challenge Radically Simplifying Distributed Application Development Development of connected systemsremains costly and frustrating • Different programming models for different tasks • Need for security and reliable messaging • Interoperability with applications on other platforms • Productive service-oriented programming model needed

  7. WCF Unified framework for rapidly building service-oriented applications

  8. WCF • What is WCF ? • Service Oriented programming model to develop connected applications. • SDK to develop and deploy services on windows. • Unifies the existing suite of .Net distributed technologies into a single programming model. Microsoft Innovation & Practice Team, MSCoE

  9. WCF Design Goals • Unifies today’s distributed technology stacks • Compose able functionality Unification “The unified programming model for rapidly building service-oriented applications on the Windows platform” Productive Service-Oriented Programming • Service-oriented programming model • Supports 4 tenets of service-orientation • WS-* interoperability with applications running on other platforms • Interoperability with today’s distributed stacks Interoperability & Integration

  10. Message Services and Clients Client Service Message

  11. Endpoint Endpoint Endpoint Endpoints Client Service Message

  12. End Points Microsoft Innovation & Practice Team, MSCoE

  13. C C C B B B A A A Address, Binding, Contract Client Service Message Address Binding Contract (Where) (How) (What)

  14. Transport Encoder Protocol(s) Transport Encoder Protocol(s) WCF Architecture: Messaging Runtime Service Contract andBehaviors Client Dispatcher Binding Address

  15. Address Every service is associated with a unique address. Microsoft Innovation & Practice Team, MSCoE

  16. Address • WCF supports following Transport Microsoft Innovation & Practice Team, MSCoE

  17. Binding • Describes how a service communicates • Specifies set of binding elements • Transport; http, tcp, np, msmq • Encoding format; text, binary, MTOM, ... • Security requirements • Reliable session requirements • Transaction requirements • Set of predefined standard bindings • Can be customized • Custom binding Microsoft Innovation & Practice Team, MSCoE

  18. Bindings & Binding Elements Binding HTTP Text Security Reliability TX Transport Protocol Encoders TCP HTTP Security Reliability Text Binary MSMQ IPC TX .NET Custom Custom Custom

  19. Binding Microsoft Innovation & Practice Team, MSCoE

  20. ASMX/WSE3 WCF MSMQ WCF WCF WCF Other Platform WCF ASMX/WSE3 WCF MSMQ WCF Other Platform WCF Choosing Bindings Any Protocol AnyBinding AnyBinding WS-* Protocols Http/WSBinding WS-* Protocols Http/WSBinding WS-* Protocols Http/WSBinding WS-* Protocols Http/WSBinding MSMQ Protocol MSMQBinding MSMQ Protocol MSMQBinding

  21. Configuring Bindings <endpoint address="Calculator" bindingSectionName="basicProfileBinding" bindingConfiguration="Binding1" contractType="ICalculator" /> <bindings> <basicProfileBinding> <binding configurationName="Binding1" hostnameComparisonMode="StrongWildcard" transferTimeout="00:10:00" maxMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" </binding></basicProfileBinding></bindings>

  22. Contracts • WCF services exposes contract. • This is a platform neutral and standard • This says , what a service will do. • Defines , what a Service communicate Microsoft Innovation & Practice Team, MSCoE

  23. Types of Contracts Microsoft Innovation & Practice Team, MSCoE

  24. Service Contracts • Describes what a service does • Maps CLR types to WSDL • [ServiceContract] defines the service contract • [OperationContract] specifies operations • One-way, request-reply, duplex MEPs, Sessions, Faults

  25. A Service Contract

  26. Data Contract • Defines data structures • Maps CLR types to XML Schema • [DataContract] specifies types • [DataMember] specifies members • Can be applied to private fields!

  27. A Data Contract

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

  29. End Points • Each service must expose at least one business endpoint. • Each End point has exactly one contract. • All endpoint on service have a unique addresses. • A single service can expose multiple end points. • Multiple exposed endpoint for single service can use same or different Bindings. • Multiple exposed endpoint for single service can use same or different Contracts. • There is no relationship in between various endpoint service provides.

  30. Defining Endpoints <?xml version="1.0" encoding="utf-8" ?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.serviceModel> <services> <service serviceType="CalculatorService"> <endpoint address="Calculator" bindingSectionName="basicProfileBinding" contractType="ICalculator" /> </service> </services> </system.serviceModel> </configuration>

  31. Hosting • WCF services can not exist in void. • It must be hosted. • WCF services are hosted in windows process called host process. • A single host process can host multiple service. • A same service can be hosted in multiple host process. Microsoft Innovation & Practice Team, MSCoE

  32. Message patterns

  33. WCF Programming Model

  34. Steps in creating WCF Service Defining .Net service interface to serve as the Service contract Implement Service Contract in .Net class as Service type and configure its behavior Configure the End Point where service will expose , by specifying A,B,C Host Service type in application using WCF hosting infrastructure At client side ,By using description of target End Point create PROXY. And write code against this Proxy.

  35. WCF basic task cycle

  36. WCF Thank You

More Related