windows communication foundation

36
WINDOWS COMMUNICATION FOUNDATION

Upload: tamra

Post on 23-Feb-2016

55 views

Category:

Documents


0 download

DESCRIPTION

Windows communication foundation. 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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Windows communication foundation

WINDOWS COMMUNICATION

FOUNDATION

Page 2: Windows communication foundation

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 3: Windows communication foundation

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 Studio 2005 using

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 4: Windows communication foundation

.NET at the core

The Unified Framework For

Rapidly Building Service-Oriented

Applications

Page 5: Windows communication foundation

Windows Communication Foundation

• Unifies today’s distributed technologies• Lets you develop/deploy/manage one

model• Visual Studio 2005 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 communicationService-OrientedDevelopment

Page 6: Windows communication foundation

Unified Programming Model

Interopwith otherplatforms

ASMX

Attribute- Based

Programming

Enterprise Services

WS-*ProtocolSupport

WSE

Message-Oriented

Programming

System.Messaging

ExtensibilityLocation transparency

.NET Remoting

Page 7: Windows communication foundation

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 8: Windows communication foundation

How does it work?Endpoints

Client Service

MessageEndpoint Endpoint

Endpoint

Page 9: Windows communication foundation

How does it work?Address, Binding, Contract

Client Service

MessageABC A B C

A B C

Address Binding Contract(Where) (How) (What)

Page 10: Windows communication foundation

How does it work?Behaviours and Metadata

Client Service

MessageABC A B C

A B C

Metadata

Bv BvBv Bv

Proxy ServiceHost()

Page 11: Windows communication foundation

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 12: Windows communication foundation

How do I use it?

Generate

Proxy

Pick Endpoi

nt

Define Contract Implement Service

Define Endpoints Host Service

Client

Service

Page 13: Windows communication foundation

How do I deploy it?

• For HTTP services on Windows XP® SP2 & WS2K3• For any service on Windows Vista® and Windows Server®

“Longhorn” • Proven reliability, scalability, and security• Requires a .svc file to identify the Service Type

Web Host within IIS:

Self-Host within any .NET process:

• Available for any service • Console apps, windowed apps, .NET NT Services …

Page 14: Windows communication foundation

Building a simple service and client

Page 15: Windows communication foundation

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 16: Windows communication foundation

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 17: Windows communication foundation

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 18: Windows communication foundation

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 19: Windows communication foundation

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 20: Windows communication foundation

All about AddressesAn 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 21: Windows communication foundation

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 22: Windows communication foundation

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 23: Windows communication foundation

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 24: Windows communication foundation

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 25: Windows communication foundation

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 26: Windows communication foundation

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 27: Windows communication foundation

Hosting WCF in ASP.NET

Page 28: Windows communication foundation

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 29: Windows communication foundation

IIS Worker Process(w3wp.exe)

Page 30: Windows communication foundation

w3wp.exe

ASP.NET

Page 31: Windows communication foundation

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 32: Windows communication foundation

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 33: Windows communication foundation

WCF and the HTTP Pipeline

IISAS

P.N

ET

HTTPRequest

Service Implementation

Process Host

WCF HttpModule(grabs *.svc)

WCF HTTP Transport

Protocol Channels

Dispatcher

HTTPResponse

Other HttpModuleOther HttpModule

Other HttpModule

Page 34: Windows communication foundation

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 35: Windows communication foundation

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 36: Windows communication foundation

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