Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It?...
-
Upload
timothy-hampton -
Category
Documents
-
view
212 -
download
0
Transcript of Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It?...
![Page 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/1.jpg)
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
![Page 2: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/2.jpg)
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 Studiousing any .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
![Page 3: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/3.jpg)
.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.
Windows Communication Foundation (WCF) ASP.NET Web Service
WCF supports multiple bindings HTTP, WSHTTP, TCP, MSMQ. ASP.NET Web Services supports only HTTP binding.
WCF supports Atomic Transactions*. ASP.NET Web Services does not support Atomic Transactions*.
By default WCF uses SOAP for sending and receiving the messages. But WCF can support any kind of message format not only SOAP.
ASP.NET Web Services can send and receive messages via the SOAP only.
The System.Runtime.Serialization.DataContract and System.Runtime.Serialization.DataMember attributes of the WCF's System.Runtime.Serialization assembly can be added for .NET types to indicate that instances of the type are to be serialized into XML, and which particular fields or properties of the type are to be serialized.
ASP.NET Web Services uses XmlSerializer to translate the XML data (Message Send or received) into .NET objects.
![Page 4: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/4.jpg)
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-OrientedDevelopment
![Page 5: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/5.jpg)
Unified Programming Model
Interopwith otherplatforms
ASMX
Attribute- Based
Programming
Enterprise Services
WS-*ProtocolSupport
WSE
Message-Oriented
Programming
System.Messaging
ExtensibilityLocation
transparency
.NET Remoting
![Page 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/6.jpg)
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
![Page 7: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/7.jpg)
How does it work?Endpoints
Client Service
MessageEndpoint Endpoint
Endpoint
![Page 8: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/8.jpg)
How does it work?Address, Binding, Contract
Client Service
MessageABC A B C
A B C
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.
![Page 9: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/9.jpg)
How does it work?Behaviours and Metadata
Client Service
MessageABC A B C
A B C
Metadata
Bv Bv
Bv Bv
Proxy ServiceHost()
![Page 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/10.jpg)
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
![Page 11: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/11.jpg)
How do I use it?
Generate Proxy
Pick Endpoint
Define Contract
Implement
Service
Define Endpoint
s
Host Service
Client
Service
![Page 12: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/12.jpg)
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 …
![Page 13: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/13.jpg)
Building a simple service and client
![Page 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/14.jpg)
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
![Page 15: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/15.jpg)
All About BindingsYou can choose a pre-defined binding:
<endpoint name=“MyService” address=“MyAddress” binding=“netTcpBinding” contract=“IMyInterface” />
NetPeerTcpBinding
NetMSMQBinding
NetNamePipesBinding
NetTcpBinding
WsHttpBinding
BasicHttpBinding
Binding
.NET Peer Peer
.NET.NET via MSMQ
.NET.NET across processesSecure, reliable duplexed
.NET.NET across processesSecure, reliable duplexed
Basis for WS-* interopSupports WS-Security, WS-RM, WS-Tx
Basic Profile 1.1 Interop and Intergration w/ASMX
Purpose
![Page 16: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/16.jpg)
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>
![Page 17: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/17.jpg)
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>
![Page 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/18.jpg)
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
![Page 19: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/19.jpg)
All about Addresses
An endpoint address is relative to a base address:
For a Web-Hosted service, the base address is that of its virtual directory
<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>
![Page 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/20.jpg)
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
![Page 21: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/21.jpg)
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.
![Page 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/22.jpg)
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
![Page 23: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/23.jpg)
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
![Page 24: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/24.jpg)
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
![Page 25: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/25.jpg)
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
![Page 26: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/26.jpg)
Hosting WCF in ASP.NET
![Page 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/27.jpg)
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
![Page 28: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/28.jpg)
IIS Worker Process(w3wp.exe)
![Page 29: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/29.jpg)
w3wp.exe
ASP.NET
![Page 30: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/30.jpg)
w3wp.exe
ASP.NET Managed Hosting Layer(System.Web.Hosting, System.Web.Compilation)
ASP.NETPage Framework, UI, Controls,HTTP Runtime(System.Web, System.Web.UI)
![Page 31: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/31.jpg)
w3wp.exe
ASP.NET Managed Hosting Layer(System.Web.Hosting, System.Web.Compilation)
ASP.NETPage Framework, UI, Controls,HTTP Runtime(System.Web, System.Web.UI)
WCF Service Model(System.ServiceModel)Can share state
![Page 32: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/32.jpg)
WCF and the HTTP Pipeline
IIS
AS
P.N
ET
HTTPRequest
Service Implementation
Process Host
WCF HttpModule(grabs *.svc)
WC
FHTTP Transport
Protocol Channels
Dispatcher
HTTPResponse
Other HttpModuleOther HttpModule
Other HttpModule
![Page 33: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/33.jpg)
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
![Page 34: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/34.jpg)
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
![Page 35: 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.](https://reader031.fdocuments.in/reader031/viewer/2022032803/56649e375503460f94b27236/html5/thumbnails/35.jpg)
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