1 / 26

Windows Communications Foundation

Windows Communications Foundation. Overview. Introduction WCF Definition WCF Architecture Implementation WCF Demo. Introduction. Web Services Everywhere…. Web Services Components. Universal Description Discovery and Integration, example. Web Services Description Language.

klaus
Download Presentation

Windows Communications 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. Windows Communications Foundation

  2. Overview • Introduction • WCF Definition • WCF Architecture • Implementation • WCF Demo

  3. Introduction

  4. Web Services Everywhere…

  5. Web Services Components Universal Description Discovery and Integration, example Web Services Description Language Define the structure of an XML document, just like a DTD Simple Object Access Protocol

  6. Client Invoking a Web Service

  7. HTTP Communication URL Verb Data POST SimpleService.asmx/EchoString HTTP/1.1 Host: localhost:1489 User-Agent: Mozilla/5.0 Accept: text/html Content-Type: application/json; Content-Length: 27 ... XML, JSON, SOAP, AtomPub ... Headers

  8. JSON vs. SOAP URL Verb POST SimpleService.asmx/EchoString HTTP/1.1 Host: localhost:1489 User-Agent: Mozilla/5.0 Accept: text/html,application/xhtml+xml Content-Type: application/json; Content-Length: 27 ... Headers Data { "Age":37, "FirstName":"Eyal", "ID":"123", "LastName":"Vardi“ } <Envelope> <Header> <!–- Headers --> <!-- Protocol's & Polices --> </Header> <Body> <!– XML Data --> </Body> </Envelope>

  9. WCF Definition

  10. Clarifying Version Confusion… .NET Framework 3.5 .NET Framework 3.0 + SP1 Visual Studio 2008 .NET Framework 2.0 + SP1 Windows Presentation Foundation Windows Communication Foundation Windows Workflow Foundation Windows CardSpace

  11. Windows Communication Foundation (WCF) • WCF designed to offer a manageable approach to: • Distributed computing. • Broad interoperability. • Direct support for service orientation. • WCF simplifies development of connected applications through a new service-oriented programming model.

  12. A Unified Programming Model Many confusing and complicated options Remoting COM DCOM WSE MSMQ ASMX COM+ WindowsCommunicationFoundation A unified development model

  13. WCF Architecture

  14. Sending a WCF Message Channel Channel Channel Channel Endpoints Channel Channel Binding Message WCF dispatcher Client Service Proxy Proxy object used to send messages to the service. Proxy hides communications complexity, and makes the remote service appears as local object. Matching Binding Listen for messages on one or more endpoints. Encoding Encoding Transport channel Transport channel

  15. Structure of a Service .NET Classes and Interface Service IIS / Standalone Managed Application Service Contracts or Metadata Exchange Service Host mex enables communication without prior knowledge of the contract (metadata about the service).

  16. Address The ABC of Endpoints Binding Where to find the service Example: http://localhost:8001/MathService Contract How to communicate with the service Example: BasicHttpBinding What the service can do for you Example: [OperationContract] int Add(int num1, int num2); A Service B C

  17. Hosting a WCF Service in a Self-Hosted Managed Application Windows Forms application Windows service Windows Console application WPF application

  18. Implementation

  19. Essential Pieces of WCF • Contracts for services, data, and messages • A contract is simply an interface declaration • Service, Data, and Message definitions • Class implementations • Configurations defined programmatically or declaratively • config files. • A host process (can be self hosted) • IIS, Windows Executable, Windows Service, or WAS • .Net Framework (3.5) Classes provide support for all of the above.

  20. WCF Service Files • IService.cs • Interface(s) that define a service, data, or message contract • Service.cs • Implement the service’s functionality • Service.svc • Markup file (with one line) used for services hosted in IIS • Configuration files that declare service attributes, endpoints, and policy • App.config (self hosted) contains service model markup • Web.config (hosted in IIS) has web server policy markup plus service model markup, as in App.config

  21. Example of a Simple Contract using System; using System.ServiceModel; namespace ConnectedWCF { [ServiceContract(Namespace="http://myuri.org/Simple") ] public interface IBank { [OperationContract] decimal GetBalance(string account); [OperationContract] void Withdraw(string account, decimal amount); [OperationContract] void Deposit(string account, decimal amount); } Attributes control exposure of types and methods

  22. Identifying WCF Entries in Configuration Files • Root element is system.serviceModel • WCF-specific elements below this have various properties and sub elements <system.serviceModel> <services> <service name="ConnectedWCF.BankService"> <endpoint address="BankService" binding="basicHttpBinding" contract="ConnectedWCF.IBank"/> <host> <baseAddresses> <baseAddress baseAddress="http://localhost:8080/Simple"/> </baseAddresses> </host> </service> </services> </system.serviceModel>

  23. Contracts, Metadata, and Artifacts Running Service Implements ServiceAssembly ServiceClass Service Metadata Generate Generate Service Interface Generate Service Proxy ServiceModel Metadata Utility Tool (Svcutil.exe) generates metadataand artifacts ProxyArtifacts Implements http://msdn.microsoft.com/en-us/library/aa347733(v=VS.90).aspx

  24. Separation of Concerns in a WCF Service WCF Service Library Contract Implementation WCF solution WCF Service Host Configuration Best Practices Host code

  25. WCF Demo

  26. WCF Standard Bindings

More Related