Service Oriented Development With Windows Communication Foundation Tulsa Dnug


Published on

Slides from my presentation to Tulsa Developers .NET on 9/29/2008

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Service Oriented Development With Windows Communication Foundation Tulsa Dnug

    1. 1. Service Oriented Development with Windows Communication Foundation Jason Townsend
    2. 2. Jason Townsend <ul><li>President, Bartlesville .NET User Group </li></ul><ul><li>Sr. Analyst, ConocoPhillips </li></ul><ul><li>11+ Years Development Experience </li></ul><ul><li>Father of 4 beautiful children </li></ul><ul><li>Competitive Sailor </li></ul>
    3. 3. Evolution of Service Orientation
    4. 4. Object-Oriented <ul><li>Polymorphism </li></ul><ul><ul><li>Lets you treat derived class members just like their parent class' members. </li></ul></ul><ul><ul><li>Process of using an operator or function in different ways for different set of inputs given. </li></ul></ul><ul><ul><li>The ability of objects belonging to different types to respond to method calls of the same name, each one according to an appropriate type-specific behavior. </li></ul></ul><ul><li>Encapsulation </li></ul><ul><ul><li>Often used interchangeably with information hiding. </li></ul></ul><ul><ul><li>Reduces software development risk by shifting the code's dependency on an uncertain implementation (design decision) onto a well-defined interface. </li></ul></ul><ul><li>Subclassing </li></ul><ul><ul><li>Subclass is a class that inherits some properties from its superclass. </li></ul></ul>
    5. 5. Component-Based <ul><li>Interface-based </li></ul><ul><ul><li>Insists that Interfaces are to be added to components. </li></ul></ul><ul><ul><li>The entire system is thus viewed as Components and the interfaces that helps them to coact. </li></ul></ul><ul><li>Dynamic Loading </li></ul><ul><ul><li>Dynamic loading is a mechanism by which a computer program can, at runtime, load a library (or other binary) into memory, retrieve the addresses of functions and variables contained in the library, execute those functions or access those variables, and unload the library from memory. </li></ul></ul><ul><li>Runtime Metadata </li></ul><ul><ul><li>Enabled the ability to build systems that dynamically loaded and bound to new functionality at runtime. </li></ul></ul>
    6. 6. Service-Oriented <ul><li>Message-based </li></ul><ul><ul><li>Communication is made by the sending of messages to recipients. </li></ul></ul><ul><ul><li>Forms of messages include function invocation, signals, and data packets. </li></ul></ul><ul><li>Schema and Contract </li></ul><ul><ul><li>Use schema to describe the structure of messages </li></ul></ul><ul><ul><li>Use contract to define acceptable message exchange patterns. </li></ul></ul><ul><li>Binding via Policy </li></ul><ul><ul><li>Use policy to define service semantics used for binding. </li></ul></ul>
    7. 7. Tenets of Service Orientation
    8. 8. Boundaries are Explicit <ul><li>Based on the underlying concept of encapsulation, this tenet specifies the publishing and consumption of functionality as sets of services that abstract their underlying implementation. </li></ul><ul><li>With WCF, the attribute-based programming enables developers to explicitly define external service contracts. Without explicitly defining these, nothing within the class will be exposed publicly. </li></ul><ul><li>WCF provides an opt-in model for explicitly defining service boundaries. </li></ul>
    9. 9. Autonomous Evolution <ul><li>Services are Autonomous. </li></ul><ul><li>Autonomy </li></ul><ul><ul><li>We design the system to support the inevitable evolution of the service’s implementation over time. As we build our services, we need to assume that their internal implementation will evolve (become versioned) over time and that our services as well as the services on which we depend could change location at (almost) any time. </li></ul></ul>
    10. 10. Share Schema & Contract, Not Class <ul><li>Services share schema and contract, not class. </li></ul><ul><ul><li>This is how ASMX works. </li></ul></ul><ul><ul><ul><li>Service publishes a contract (WSDL, XSD) </li></ul></ul></ul><ul><ul><ul><li>No types are shared between service and its client (by default) </li></ul></ul></ul><ul><ul><li>Neither service requires knowledge of each others’ internal workings in order to exchange data. </li></ul></ul>
    11. 11. Compatibility Based on Policy <ul><li>Service compatibility is determined based on policy. </li></ul><ul><li>Services communicate through dynamically negotiated communications channels that support the necessary semantics. </li></ul><ul><li>Service policy statements created automatically based on configuration, class attributes, and method signatures. </li></ul><ul><li>Client channels automatically configured via retrieved service policy. </li></ul>
    12. 12. Why Service Orientation? <ul><li>Facilitates loosely coupled standards based integration. </li></ul><ul><li>Enables independence in deployment, versioning, and management of the client (caller) and the server (called). </li></ul><ul><li>Promotes reuse of application investments over time. </li></ul>
    13. 13. WCF Design Goals
    14. 14. WS-* <ul><li>Used as a reference to many web service based standards covering topics such as: </li></ul><ul><ul><li>XML Specifications </li></ul></ul><ul><ul><li>Messaging Specifications </li></ul></ul><ul><ul><li>Metadata Exchange Specifications </li></ul></ul><ul><ul><li>Security Specifications </li></ul></ul><ul><ul><li>Privacy </li></ul></ul><ul><ul><li>Reliable Messaging Specifications </li></ul></ul><ul><ul><li>Resource Specifications </li></ul></ul><ul><ul><li>Web Services Interoperability organization (WS-I) Specifications </li></ul></ul><ul><ul><li>Business Process Specifications </li></ul></ul><ul><ul><li>Transaction Specifications </li></ul></ul><ul><ul><li>Management Specifications </li></ul></ul>
    15. 15. XML Specifications <ul><li>XML (eXtensible Markup Language) </li></ul><ul><li>XML Namespaces </li></ul><ul><li>XML Schema </li></ul><ul><li>XPath </li></ul><ul><li>XQuery </li></ul><ul><li>XML Information Set </li></ul><ul><li>XInclude </li></ul><ul><li>XML Pointer </li></ul>
    16. 16. Messaging Specifications <ul><li>Simple Object Access Protocol (SOAP) </li></ul><ul><li>SOAP Message Transmission Optimization Mechanism </li></ul><ul><li>WS-Notification </li></ul><ul><ul><li>WS-BaseNotification </li></ul></ul><ul><ul><li>WS-Topics </li></ul></ul><ul><ul><li>WS-BrokeredNotification </li></ul></ul><ul><li>WS-Addressing </li></ul><ul><li>WS-Transfer </li></ul><ul><li>WS-Eventing </li></ul><ul><li>WS-Enumeration </li></ul>
    17. 17. Metadata Exchange Specifications <ul><li>WS-Policy </li></ul><ul><li>WS-PolicyAssertions </li></ul><ul><li>WS-PolicyAttachment </li></ul><ul><li>WS-Discovery </li></ul><ul><ul><li>WS-Inspection </li></ul></ul><ul><li>WS-MetadataExchange </li></ul><ul><li>Universal Description, Discovery, and Integration (UDDI) </li></ul><ul><li>WSDL 2.0 Core </li></ul><ul><li>WSDL 2.0 SOAP Binding </li></ul><ul><ul><li>Web Services Semantics (WSDL-S) </li></ul></ul><ul><li>WS-Resource Framework (WSRF) </li></ul>
    18. 18. Security Specifications <ul><li>WS-Security </li></ul><ul><li>XML Signature </li></ul><ul><li>XML Encryption </li></ul><ul><li>XML Key Management (XKMS) </li></ul><ul><li>WS-SecureConversation </li></ul><ul><li>WS-SecurityPolicy </li></ul><ul><li>WS-Trust </li></ul><ul><li>WS-Federation </li></ul><ul><li>WS-Federation Active Requestor Profile </li></ul><ul><li>WS-Federation Passive Requestor Profile </li></ul><ul><li>Web Services Security Kerberos Binding </li></ul><ul><li>Web Single Sign-On Interoperability Profile </li></ul><ul><li>Web Single Sign-On Metadata Exchange Protocol </li></ul><ul><li>Security Assertion Markup Language (SAML) </li></ul><ul><li>XACML </li></ul>
    19. 19. Privacy <ul><li>P3P </li></ul>Reliable Messaging <ul><li>WS-ReliableMessaging </li></ul><ul><li>WS-Reliability </li></ul><ul><li>WS-RM Policy Assertion </li></ul>
    20. 20. Resource Specifications <ul><li>Web Services Resource Framework </li></ul><ul><li>WS-BaseFaults </li></ul><ul><li>WS-ServiceGroup </li></ul><ul><li>WS-ResourceProperties </li></ul><ul><li>WS-ResourceLifetime </li></ul><ul><li>WS-Transfer </li></ul><ul><li>Resource Representation SOAP Header Block </li></ul>
    21. 21. Web Services Interoperability Organization (WS-I) Specifications <ul><li>WS-I Basic Profile </li></ul><ul><li>WS-I Basic Security Profile </li></ul><ul><li>Simple Soap Binding Profile </li></ul>
    22. 22. Business Process Specifications <ul><li>WS-BPEL </li></ul><ul><li>WS-CDL </li></ul><ul><li>Web Services Choreography Interface </li></ul><ul><li>WS-Choreography </li></ul><ul><li>XML Process Definition Language </li></ul>
    23. 23. Transaction Specifications <ul><li>WS-BusinessActivity </li></ul><ul><li>WS-AtomicTransaction </li></ul><ul><li>WS-Coordination </li></ul><ul><li>WS-CAF </li></ul><ul><li>WS-Transaction </li></ul><ul><li>WS-Context </li></ul><ul><li>WS-CF </li></ul>
    24. 24. Management Specifications <ul><li>WS-Management </li></ul><ul><li>WS-Management Catalog </li></ul><ul><li>WS-ResourceTransfer </li></ul><ul><li>WSDM </li></ul>
    25. 25. WCF Make WS-* Easy <ul><li>Binding selection abstracts WS-* internals </li></ul><ul><li>WCF has Oasis Standard Bindings (3.5) </li></ul><ul><li>Single Object model for </li></ul><ul><ul><li>Transports </li></ul></ul><ul><ul><li>Choreographies </li></ul></ul><ul><ul><li>Message Exchange Patterns (MEPs) </li></ul></ul><ul><ul><li>Etc… </li></ul></ul>
    26. 26. REST <ul><li>Focus is on the URI </li></ul><ul><ul><li>HTTP GET </li></ul></ul><ul><ul><li>HTTP POST </li></ul></ul><ul><li>GET is special, other verbs are application specific </li></ul><ul><ul><li>GET verb always means “View It” </li></ul></ul><ul><ul><li>PUT/POST/DELETE mean “Do It” but depend on client implementation </li></ul></ul><ul><li>Content Type is the data model </li></ul><ul><ul><li>XML </li></ul></ul><ul><ul><li>JSON </li></ul></ul><ul><ul><li>Binary </li></ul></ul><ul><ul><li>Etc... </li></ul></ul><ul><li>Support built on via WCF extensibility points </li></ul>
    27. 27. WS-* versus REST <ul><li>Which is better? </li></ul><ul><li>Each has strengths: </li></ul><ul><ul><li>REST: proliferation of clients, easy to understand </li></ul></ul><ul><ul><ul><li>Flash </li></ul></ul></ul><ul><ul><ul><li>Silverlight </li></ul></ul></ul><ul><ul><ul><li>Javascript </li></ul></ul></ul><ul><ul><ul><li>Etc… </li></ul></ul></ul><ul><ul><li>WS-*: rich Messaging Exchange patterns, Topologies, and Choreographies </li></ul></ul>
    28. 28. WCF Architecture (Application)
    29. 29. Messaging <ul><li>WS Security Channel </li></ul><ul><li>WS Reliable Messaging Channel </li></ul><ul><li>Encoders: Binary/MTOM/Text/XML </li></ul><ul><li>HTTP Channel </li></ul><ul><li>TCP Channel </li></ul><ul><li>Transaction Flow Channel </li></ul><ul><li>NamedPipe Channel </li></ul><ul><li>MSMQ Channel </li></ul>
    30. 30. Communicating through Messages <ul><li>Messages travel between communication parties </li></ul><ul><li>Messages can be grouped into different message exchange patterns (MEPs) </li></ul><ul><li>MEPs can be implemented synchronously or asynchronously </li></ul><ul><li>WCF supports different MEPs </li></ul><ul><li>WCF MEPs implemented by different kinds of channels </li></ul>
    31. 32. Channel Shaping (Message Exchange Patterns) <ul><li>Possible mismatch: </li></ul><ul><ul><li>Physical transport </li></ul></ul><ul><ul><li>Logical message exchange patterns </li></ul></ul><ul><li>Channel shapes implemented in transport bindings </li></ul><ul><ul><li>Express support for Message Exchange Patterns </li></ul></ul><ul><li>WCF ServiceModel analyzes contract </li></ul><ul><ul><li>Which channel shapes will be supported? </li></ul></ul><ul><li>ServiceChannelFactory.BuildChannelFactory and DispatcherBuilder.GetSupportedChannelTypes have the details </li></ul>
    32. 33. Contracts <ul><li>Service Contract </li></ul><ul><ul><li>Operations </li></ul></ul><ul><ul><li>Behaviors </li></ul></ul><ul><ul><li>Communication Shape </li></ul></ul><ul><li>Data Contract </li></ul><ul><ul><li>Schema and Versioning Strategy </li></ul></ul><ul><li>Message Contract </li></ul><ul><ul><li>Application specific headers and unwrapped body content </li></ul></ul><ul><li>Policy and Binding </li></ul>
    33. 34. Contracts (Request-Reply) <ul><li>Most commonly used MEP </li></ul><ul><ul><li>It is easy to use and looks natural </li></ul></ul><ul><li>R/R can be implemented in WCF by several approaches </li></ul><ul><ul><li>Parameter list </li></ul></ul><ul><ul><li>DataContract </li></ul></ul><ul><ul><li>MessageContract </li></ul></ul><ul><ul><li>Message </li></ul></ul><ul><li>Mind the “public face” of contracts, i.e. the metadata </li></ul>
    34. 35. Contracts (One-Way) <ul><li>One Way operations smell more feasible when decoupling is goal </li></ul><ul><li>No return values, rather void </li></ul><ul><li>Use IsOneWay property of OperationContract </li></ul><ul><li>OneWay operations can still block </li></ul><ul><ul><li>Not really fire-and-forget semantics </li></ul></ul>
    35. 36. Contracts (Duplex) <ul><li>Having peer communication parties </li></ul><ul><ul><li>Blurring the line between client and server </li></ul></ul><ul><li>Use CallbackContract property of ServiceContract </li></ul><ul><li>Operations in contracts can be one-way, but need no to be </li></ul><ul><ul><li>If using non-one-way beware of threading issues </li></ul></ul>
    36. 37. Contracts (Streaming) <ul><li>Buffered communication can be very expensive with large data </li></ul><ul><li>WCF offers streamed transfer </li></ul><ul><ul><li>Contract parameters must have certain shape </li></ul></ul><ul><li>Use Message, IXmlSerializable or System.IO.Stream or derivate as type </li></ul><ul><li>Use MessageContract </li></ul><ul><ul><li>Headers will be buffered </li></ul></ul><ul><ul><li>Body as System.IO.Stream will be streamed </li></ul></ul><ul><li>Only works with appropriate binding </li></ul>
    37. 38. Transport Protocols (Bindings) <ul><li>HTTP </li></ul><ul><li>TCP </li></ul><ul><li>MSMQ </li></ul><ul><li>More can be added through built-in extension points. </li></ul>
    38. 39. Bindings (Request-Reply) <ul><li>Almost all out-of-the-box bindings support request-reply </li></ul><ul><ul><li>MSMQ-based bindings do not </li></ul></ul><ul><li>For all bindings and MEPs: </li></ul><ul><ul><li>Beware of default min/max values on binding elements for e.g. message sizes and buffers and timeouts </li></ul></ul><ul><ul><li>Beware of possible throttles on service behavior </li></ul></ul>
    39. 40. Bindings (One-Way) <ul><li>All bindings support one-way operations </li></ul><ul><li>Use OneWayBindingElement for custom bindings to shape channel </li></ul><ul><ul><li>Performs a message-level shape change </li></ul></ul><ul><ul><li>Can take a IDuplexSessionChannel or a IRequestChannel and expose it as a IOutputChannel, or conversely it can take a IDuplexSessionChannel or a IReplyChannel and expose it as a IInputChannel </li></ul></ul>
    40. 41. Bindings (Duplex) <ul><li>Duplex out-of-the-box </li></ul><ul><ul><li>netTcp </li></ul></ul><ul><ul><li>wsDualHttp </li></ul></ul><ul><ul><li>netNamedPipe </li></ul></ul><ul><ul><li>netPeerTcp </li></ul></ul><ul><li>Manual duplex session-less, e.g. </li></ul><ul><ul><li><compositeDuplex /> </li></ul></ul><ul><ul><li><oneWay /> </li></ul></ul><ul><ul><li><binaryMessageEncoding /> </li></ul></ul><ul><ul><li><httpTransport /> </li></ul></ul>
    41. 42. Bindings (Streaming) <ul><li>Enable streaming on the baked-in bindings </li></ul><ul><ul><li>All standard bindings besides MSMQ-based </li></ul></ul><ul><li>Enable streaming on the transport binding element, e.g. </li></ul><ul><ul><li><httpTransport transferMode=„Streamed“ /> </li></ul></ul><ul><li>Possible transferMode values </li></ul><ul><ul><li>Buffered </li></ul></ul><ul><ul><li>Streamed </li></ul></ul><ul><ul><li>StreamedRequest </li></ul></ul><ul><ul><li>StreamedResponse </li></ul></ul><ul><li>Only transport security and no reliable sessions allowed </li></ul>
    42. 43. MSMQ Transport <ul><li>MSMQ is different – always has been </li></ul><ul><li>Duplex Message Exchange Pattern over MSMQ-based binding can be achieved manually: </li></ul><ul><ul><li>Leverage message headers </li></ul></ul><ul><ul><li>Access headers through OperationContext in user code </li></ul></ul><ul><ul><li>Access headers through message inspectors in ServiceModel extensions </li></ul></ul><ul><ul><li>Use GUID to correlate messages </li></ul></ul>
    43. 44. Service Runtime <ul><li>Throttling Behavior </li></ul><ul><li>Error Behavior </li></ul><ul><li>Metadata Behavior </li></ul><ul><li>Instance Behavior </li></ul><ul><li>Message Inspection </li></ul><ul><li>Transaction Behavior </li></ul><ul><li>Dispatch Behavior </li></ul><ul><li>Concurrency Behavior </li></ul><ul><li>Parameter Filtering </li></ul>
    44. 45. WCF Reliability and Transactions <ul><li>End-to-End Reliable Messaging </li></ul><ul><ul><li>In-Order guarantees </li></ul></ul><ul><ul><li>Exactly once guarantees </li></ul></ul><ul><li>Transport-Independent Sessions </li></ul><ul><ul><li>Integration with ASP.NET Sessions in IIS-Hosted compatibility mode </li></ul></ul><ul><li>Transactions </li></ul><ul><ul><li>Guaranteed atomic success or failure across services </li></ul></ul>
    45. 46. WCF Instancing, Concurrency, and Sessions <ul><li>Service classes can be instantiated </li></ul><ul><ul><li>Singleton </li></ul></ul><ul><ul><li>Per-Call </li></ul></ul><ul><ul><li>Per-Session </li></ul></ul><ul><ul><li>Shareable </li></ul></ul><ul><li>Service code can be either: </li></ul><ul><ul><li>Single-threaded </li></ul></ul><ul><ul><li>Re-entrant </li></ul></ul><ul><ul><li>Multi-threaded </li></ul></ul>
    46. 47. WCF Security <ul><li>Claims based end-to-end security </li></ul><ul><ul><li>Secure end-to-end message exchanges </li></ul></ul><ul><ul><li>Secure access to resources </li></ul></ul><ul><ul><li>Record resource access requests </li></ul></ul><ul><li>X509, Username/Password, Kerberos, SAML, and custom credentials </li></ul><ul><li>Message Security </li></ul><ul><ul><li>Confidentiality and Integrity </li></ul></ul><ul><ul><li>Transport or Message Level </li></ul></ul><ul><li>Access to resources </li></ul><ul><ul><li>Authentication and Authorization </li></ul></ul>
    47. 48. Hosting and Activation <ul><li>Windows Activation Service/IIS </li></ul><ul><li>.EXE </li></ul><ul><li>Windows Services </li></ul><ul><li>COM+ </li></ul>
    48. 49. WCF Offers Features You Need <ul><li>Logging </li></ul><ul><li>Tracing </li></ul><ul><li>Instance Control </li></ul><ul><li>Throttling </li></ul><ul><li>Rich Configuration </li></ul><ul><li>Extensibility </li></ul><ul><li>Hosting Options </li></ul><ul><li>And More…. </li></ul>
    49. 50. WCF Summary <ul><li>WCF is the future of distributed computing </li></ul><ul><li>It combines the best of all existing Microsoft distributed computing stacks </li></ul><ul><li>It uses WS-* standards for interoperability and .NET value-add for performance and integration with existing solutions. </li></ul>
    50. 52. Further Resources <ul><li>My Blog </li></ul><ul><ul><li> </li></ul></ul><ul><li>Linkedin </li></ul><ul><ul><li> </li></ul></ul><ul><li>Bartlesville .NET User Group </li></ul><ul><ul><li> </li></ul></ul><ul><li>Twitter </li></ul><ul><ul><li> </li></ul></ul><ul><li>Email </li></ul><ul><ul><li>[email_address] </li></ul></ul>
    51. 53. Key Terms
    52. 54. Message <ul><li>A message is a self-contained unit of data that may consist of several parts, including a body and headers. </li></ul>
    53. 55. Service <ul><li>A service is a construct that exposes one or more endpoints, with each endpoint exposing one or more service operations. </li></ul>
    54. 56. Endpoint <ul><li>An endpoint is a construct at which messages are sent or received (or both). It comprises a location (an address) that defines where messages can be sent, a specification of the communication mechanism (a binding) that described how messages should be sent, and a definition for a set of messages that can be sent or received (or both) at that location (a service contract) that describes what message can be sent. </li></ul><ul><li>An WCF service is exposed to the world as a collection of endpoints. </li></ul>
    55. 57. Application Endpoint <ul><li>An endpoint exposed by the application and that corresponds to a service contract implemented by the application. </li></ul>
    56. 58. Infrastructure Endpoint <ul><li>An endpoint that is exposed by the infrastructure to facilitate functionality that is needed or provided by the service that does not relate to a service contract. For example, a service might have an infrastructure endpoint that provides metadata information. </li></ul>
    57. 59. Address <ul><li>An address specifies the location where messages are received. It is specified as a Uniform Resource Identifier (URI). The URI schema part names the transport mechanism to use to reach the address, such as HTTP and TCP. The hierarchical part of the URI contains a unique location whose format is dependent on the transport mechanism. </li></ul><ul><li>The endpoint address enables you to create unique endpoint addresses for each endpoint in a service, or under certain conditions share an address across endpoints. The following example shows an address using the HTTPS protocol with a non-default port: </li></ul><ul><li>HTTPS://okcodemonkey:8080/Service/MonkeyService </li></ul>
    58. 60. Binding <ul><li>A binding defines how an endpoint communicates to the world. It is constructed of a set of components called binding elements that &quot;stack&quot; one on top of the other to create the communication infrastructure. At the very least, a binding defines the transport (such as HTTP or TCP) and the encoding being used (such as text or binary). A binding can contain binding elements that specify details like the security mechanisms used to secure messages, or the message pattern used by an endpoint. For more information, see Configuring Services. </li></ul>
    59. 61. Binding Element <ul><li>A binding element represents a particular piece of the binding, such as a transport, an encoding, an implementation of an infrastructure-level protocol (such as WS-ReliableMessaging), or any other component of the communication stack. </li></ul>
    60. 62. Behaviors <ul><li>A behavior is a component that controls various run-time aspects of a service, an endpoint, a particular operation, or a client. Behaviors are grouped according to scope: common behaviors affect all endpoints globally, service behaviors affect only service-related aspects, endpoint behaviors affect only endpoint-related properties, and operation-level behaviors affect particular operations. For example, one service behavior is throttling, which specifies how a service reacts when an excess of messages threaten to overwhelm its handling capabilities. An endpoint behavior, on the other hand, controls only aspects relevant to endpoints, such as how and where to find a security credential. </li></ul>
    61. 63. System-Provided Bindings
    62. 64. Configuration versus Coding <ul><li>Control of an application can be done either through coding, through configuration, or through a combination of both. Configuration has the advantage of allowing someone other than the developer (for example, a network administrator) to set client and service parameters after the code is written and without having to recompile. Configuration not only enables you to set values like endpoint addresses, but also allows further control by enabling you to add endpoints, bindings, and behaviors. Coding allows the developer to retain strict control over all components of the service or client, and any settings done through the configuration can be inspected and if needed overridden by the code. </li></ul>
    63. 65. Service Operation <ul><li>A service operation is a procedure defined in a service's code that implements the functionality for an operation. This operation is exposed to clients as methods on a WCF client. The method may return a value, and may take an optional number of arguments, or take no arguments, and return no response. For example, an operation that functions as a simple &quot;Hello&quot; can be used as a notification of a client's presence and to begin a series of operations. </li></ul>
    64. 66. Service Contract <ul><li>The service contract ties together multiple related operations into a single functional unit. The contract can define service-level settings, such as the namespace of the service, a corresponding callback contract, and other such settings. In most cases, the contract is defined by creating an interface in the programming language of your choice and applying the ServiceContractAttribute attribute to the interface. The actual service code results by implementing the interface. </li></ul>
    65. 67. Operation Contract <ul><li>An operation contract defines the parameters and return type of an operation. When creating an interface that defines the service contract, you signify an operation contract by applying the OperationContractAttribute attribute to each method definition that is part of the contract. The operations can be modeled as taking a single message and returning a single message, or as taking a set of types and returning a type. In the latter case, the system will determine the format for the messages that need to be exchanged for that operation. </li></ul>
    66. 68. Message Contract <ul><li>A message contract describes the format of a message. For example, it declares whether message elements should go in headers versus the body, what level of security should be applied to what elements of the message, and so on. </li></ul>
    67. 69. Fault Contract <ul><li>A fault contract can be associated with a service operation to denote errors that can be returned to the caller. An operation can have zero or more faults associated with it. These errors are SOAP faults that are modeled as exceptions in the programming model. </li></ul>
    68. 70. Data Contract <ul><li>The data types a service uses must be described in metadata to enable others to interoperate with the service. The descriptions of the data types are known as the data contract, and the types can be used in any part of a message, for example, as parameters or return types. If the service is using only simple types, there is no need to explicitly use data contracts. </li></ul>
    69. 71. Hosting <ul><li>A service must be hosted in some process. A host is an application that controls the lifetime of the service. Services can be self-hosted or managed by an existing hosting process. </li></ul>
    70. 72. Self-Hosted Service <ul><li>A self-hosted service is one that runs within a process application that the developer created. The developer controls its lifetime, sets the properties of the service, opens the service (which sets it into a listening mode), and closes the service. </li></ul>
    71. 73. Hosting Process <ul><li>A hosting process is an application that is designed to host services. These include Internet Information Services (IIS), Windows Activation Services (WAS), and Windows Services. In these hosted scenarios, the host controls the lifetime of the service. For example, using IIS you can set up a virtual directory that contains the service assembly and configuration file. When a message is received, IIS starts the service and controls its lifetime. </li></ul>
    72. 74. Instancing <ul><li>A service has an instancing model. There are three instancing models: &quot;single,&quot; in which a single CLR object services all the clients; &quot;per call,&quot; in which a new CLR object is created to handle each client call; and &quot;per session,&quot; in which a set of CLR objects are created, one for each separate session. The choice of an instancing model depends on the application requirements and the expected usage pattern of the service. </li></ul>
    73. 75. Client Application <ul><li>A client application is a program that exchanges messages with one or more endpoints. The client application begins by creating an instance of a WCF client and calling methods of the WCF client. It is important to note that a single application can be both a client and a service. </li></ul>
    74. 76. Channel <ul><li>A channel is a concrete implementation of a binding element. The binding represents the configuration, and the channel is the implementation associated with that configuration. Therefore, there is a channel associated with each binding element. Channels stack on top of each other to create the concrete implementation of the binding: the channel stack. </li></ul>
    75. 77. WCF Client <ul><li>A WCF client is a client-application construct that exposes the service operations as methods (in the .NET Framework programming language of your choice, such as Visual Basic or Visual C#). Any application can host a WCF client, including an application that hosts a service. Therefore, it is possible to create a service that includes WCF clients of other services. </li></ul><ul><li>A WCF client can be automatically generated by using the ServiceModel Metadata Utility Tool (Svcutil.exe) and pointing it at a running service that publishes metadata. </li></ul>
    76. 78. Metadat <ul><li>The metadata of a service describes the characteristics of the service that an external entity needs to understand to communicate with the service. Metadata can be consumed by the ServiceModel Metadata Utility Tool (Svcutil.exe) to generate a WCF client and accompanying configuration that a client application can use to interact with the service. </li></ul><ul><li>The metadata exposed by the service includes XML schema documents, which define the data contract of the service, and WSDL documents, which describe the methods of the service. </li></ul><ul><li>When enabled, metadata for the service is automatically generated by WCF by inspecting the service and its endpoints. To publish metadata from a service, you must explicitly enable the metadata behavior. </li></ul>
    77. 79. Security <ul><li>Security in WCF includes confidentiality (encryption of messages to prevent eavesdropping), integrity (the means for detection of tampering with the message), authentication (the means for validation of servers and clients), and authorization (the control of access to resources). These functions are provided by either leveraging existing security mechanisms, such as TLS over HTTP (also known as HTTPS), or by implementing one or more of the various WS-* security specifications. </li></ul>
    78. 80. Transport Security Mode <ul><li>Security can be provided by one of three modes: transport mode, message security mode, and transport with message credential mode. The transport security mode specifies that confidentiality, integrity, and authentication are provided by the transport layer mechanisms (such as HTTPS). When using a transport like HTTPS, this mode has the advantage of being efficient in its performance, and well understood because of its prevalence on the Internet. The disadvantage is that this kind of security is applied separately on each hop in the communication path, making the communication susceptible to a &quot;man in the middle&quot; attack. </li></ul>
    79. 81. Message Security Mode <ul><li>Message security mode specifies that security is provided by implementing one or more of the security specifications. Each message contains the necessary mechanisms to provide security during its transit, and to enable the receivers to detect tampering and to decrypt the messages. In this sense, the security is encapsulated within every message, providing end-to-end security across multiple hops. Because security information becomes part of the message, it is also possible to include multiple kinds of credentials with the message (these are referred to as claims). This approach also has the advantage of enabling the message to travel securely over any transport, including multiple transports between its origin and destination. The disadvantage of this approach is the complexity of the cryptographic mechanisms employed, resulting in performance implications. </li></ul>
    80. 82. Transport with Message Credential Security Mode <ul><li>This mode uses the transport layer to provide confidentiality, authentication, and integrity of the messages, while each of the messages can contain multiple credentials (claims) required by the receivers of the message. </li></ul>
    81. 83. WS-* <ul><li>Shorthand for the growing set of Web Service (WS) specifications, such as WS-Security, WS-ReliableMessaging, and so on, that are implemented in WCF. </li></ul>