1 / 35

Agenda

Agenda. What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET. WCF is. Our next-generation platform for distributed systems

skip
Download Presentation

Agenda

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. Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

  2. WCF is • Our next-generation platform for distributed systems • A set of extensions to the Microsoft.NET Framework 2.0 • Build WCF services in Visual Studiousingany .NET Language • Intelligent code editing, IDE Extensions for WCF, debugging, re-factoring, code snippets, etc. • Visual Basic .NET, Visual C#, etc. • Runs on • Microsoft Windows Vista • Microsoft Windows XP • Microsoft Windows Server 2003

  3. .NET at the core The Unified Framework For Rapidly Building Service-Oriented Applications WCF combines the functionality from ASP.NET Web Services, .NET Remoting, Message Queuing and Enterprise Services.

  4. Windows Communication Foundation • Unifies today’s distributed technologies • Lets you develop/deploy/manage one model • Visual Studio.NET integration Unification • Broad support for Web services (WS-*) specifications • Compatible with existing Microsoft-distributed application technologies Interoperability • Enables development of loosely-coupled services • Config-based communication Service-Oriented Development

  5. Unified Programming Model .NET Remoting ASMX Interop with other platforms Extensibility Location transparency Attribute- Based Programming Message- Oriented Programming WS-* Protocol Support Enterprise Services System.Messaging WSE

  6. Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

  7. How does it work?Endpoints Endpoint Endpoint Endpoint Client Service Message

  8. How does it work?Address, Binding, Contract C C C B B B A A A Endpoints - All communications with the WCF service will happen via the endpoints. The endpoint is composed of 3 parts (collectively called as ABC's of endpoint) as defines below: Address: The endpoints specify a Address that defines where the endpoint is hosted. Contract: The endpoints specify a Contract that defines which methods of the Service class will be accessible via the endpoint; each endpoint may expose a different set of methods. Binding: The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted.Various components of the WCF are depicted in the figure below. Service Client Message

  9. How does it work?Behaviours and Metadata C C C B B B A A A Metadata Client Service Bv Bv Message Bv Bv Proxy ServiceHost()

  10. Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

  11. How do I use it? Service Client

  12. How do I deploy it? Web Host within IIS: Self-Host within any .NET process: • Available for any service • Console apps, windowed apps, .NET NT Services …

  13. Building a simple service and client

  14. Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

  15. All About BindingsYou can choose a pre-defined binding: Binding Purpose BasicHttpBinding Basic Profile 1.1 Interop and Intergration w/ASMX WsHttpBinding Basis for WS-* interop Supports WS-Security, WS-RM, WS-Tx NetTcpBinding .NET.NET across processes Secure, reliable duplexed NetNamePipesBinding .NET.NET across processes Secure, reliable duplexed NetMSMQBinding .NET.NET via MSMQ NetPeerTcpBinding .NET Peer  Peer <endpoint name=“MyService” address=“MyAddress” binding=“netTcpBinding” contract=“IMyInterface” />

  16. All About BindingsYou can customize a pre-defined binding: <services> <service name=“MyService”> <endpoint address=“MyAddress” binding=“wsHttpBinding” bindingConfiguration=“MyReliableBinding” contract=“IMyInterface” /> <service/> </services> <bindings> <wsHttpBinding> <binding name=“MyReliableBinding”> <reliableSession enabled=“true” ordered=“true” </binding> </wsHttpBinding> </bindings>

  17. All About BindingsYou can define custom bindings: <services> <service name=“MyService”> <endpoint address=“MyAddress” binding=“wsHttpBinding” bindingConfiguration=“MyReliableBinding” contract=“IMyInterface” /> <service/> </services> <bindings> <wsHttpBinding> <binding name=“MyReliableBinding”> <reliableSession enabled=“true” ordered=“true” </binding> </wsHttpBinding> </bindings>

  18. Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

  19. All about Addresses An endpoint address is relative to a base address: <services> <host> <baseAddresses> <add baseAddress="http://localhost:8000/MyBaseAddress"/> </baseAddresses> </host> <service name=“MyService”> <endpoint address=“MyEndpointAddress” binding=“wsHttpBinding” bindingConfiguration=“MyReliableBinding” contract=“IMyInterface” /> <service/> </services> For a Web-Hosted service, the base address is that of its virtual directory

  20. Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

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

  22. Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

  23. Hosting Services in ASP.NET • Write your service as usual: • [ServiceContract] • [OperationContract] etc. • ServiceHost’s are represented as .svc files: <% @ServiceHost Service=“HelloService” %> • Service attribute is a CLR type name • Matches <service name=“xxx”> from web.config

  24. Where can I put my service code? • Anywhere you can put code in ASP.NET: • Inline in the .svc file • In a .cs/.vb in App_Code • In a class library (.dll) located in \bin • WCF plays nicely with ASP.NET’s dynamic compilation system

  25. Which project type should I use? • Services can be built in any project type • Web projects • Class Libraries • Class libraries have benefits • Decouples implementation from hosting environment • Can test services in other hosts (e.g. console apps) during development • However, WCF doesn’t care which project type you use…use what makes sense for you

  26. Hosting WCF in ASP.NET

  27. Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

  28. IIS Worker Process (w3wp.exe)

  29. w3wp.exe ASP.NET

  30. w3wp.exe ASP.NET Page Framework, UI, Controls, HTTP Runtime (System.Web, System.Web.UI) ASP.NET Managed Hosting Layer(System.Web.Hosting, System.Web.Compilation)

  31. w3wp.exe ASP.NET Page Framework, UI, Controls, HTTP Runtime (System.Web, System.Web.UI) WCF Service Model (System.ServiceModel) Can share state ASP.NET Managed Hosting Layer(System.Web.Hosting, System.Web.Compilation)

  32. Service Implementation WCF WCF and the HTTP Pipeline Dispatcher Protocol Channels ASP.NET HTTP Transport Other HttpModule IIS WCF HttpModule(grabs *.svc) Other HttpModule Other HttpModule Process Host HTTP Request HTTP Response

  33. Why the split? • Two technologies, different priorities • WCF: consistency across transports and hosting environments • ASP.NET: optimize for HTTP applications hosted in IIS • Becomes very important on IIS7/WAS • WAS == Windows Process Activation Service

  34. Implications • ASP.NET platform features still work for ASP.NET • Forms auth • Session state • File/URL authorization • They just don’t apply to WCF by default

  35. Summary What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services in ASP.NET How WCF works inside of ASP.NET

More Related