The Microsoft Technical Roadshow 2006 Windows Communication Foundation Mike Taulty Developer &...

Preview:

Citation preview

The Microsoft

Technical Roadshow 2006

Windows Communication Windows Communication FoundationFoundation

Mike TaultyMike Taulty

Developer & Platform GroupDeveloper & Platform Group

Microsoft LtdMicrosoft Ltd

Mike.Taulty@microsoft.comMike.Taulty@microsoft.com

http://mtaulty.comhttp://mtaulty.com

Windows Communication Windows Communication FoundationFoundation

•Distributed ApplicationsDistributed Applications•ThemesThemes

•Service OrientationService Orientation•Unifying Programming ModelsUnifying Programming Models•Declarative DevelopmentDeclarative Development

Distributed ApplicationsDistributed Applications

‘Client’Message

Message

Services pass messages described by a contractServices pass messages described by a contract

Service may provide metadataService may provide metadataDescribing the contractDescribing the contract

Describing the policy it applies to communicationDescribing the policy it applies to communication

‘Service’

Metadata

Message (SOAP)

Headers: Addressing, Security, etc

Body: Payload

Unifying Programming ModelsUnifying Programming Models

ASMX

Interoperable

WSE

Interoperable

Secure

Remoting

Fast

Secure

‘Objects’

COM+

Fast

Secure

Transactions

MSMQ

Queued

Secure

Transactions

Scenario – Communication FoundationScenario – Communication Foundation

IIS

Upload Service

Access Service

Windows Service

Admin Service

Submit ServiceViewer

HTTP

Submitter

HTTPS

Authentication

Authorisation

Reliable Messaging

Sessions

MSMQ

Publisher Approver

HTTPS

Authentication

Authorisation

What do I send?

Where do I send it?

How should I send it?

Contract

Address

Binding

Mechanics of CommunicationMechanics of Communication

‘Service’‘Client’

Transport?

Encoding?

Security?

Mechanics of CommunicationMechanics of Communication

‘Service’‘Client’

EndpointContractBindingAddress

EndpointContractBindingAddress

EndpointContractBindingAddress

ContractsContracts[ServiceContract]

public interface INuggetAccess

{

[OperationContract] string[] GetTopics();

}

.NET Interface

<definitions>

<portType>

<operation name=“GetTopics”> …

</portType>

</definitions>

WSDL

svcutil.exe

'Service''Client'

[ServiceContract]

public interface INuggetAccess

{

[OperationContract] string[] GetTopics();

}

public class NuggetAccessService :

INuggetAccess

{ string[] GetTopics() { }

}

Implements

Consumes

request metadata (WSDL)

[ServiceContract]

public interface INuggetAccess {

[OperationContract] List<TopicInfo> GetTopics();

}

Service

Contract DetailsContract Details

Message exchange might beMessage exchange might beOne-way, request/response, two-way (Duplex)One-way, request/response, two-way (Duplex)

WCF also supports serialisation models from .NET 2.0WCF also supports serialisation models from .NET 2.0System.Xml.XmlSerialization, System.Runtime.SerializationSystem.Xml.XmlSerialization, System.Runtime.Serialization

[DataContract(Namespace=…)]

public class TopicInfo {

[DataMember]

public int Id

}

Data

[MessageContract]

public class TypedMessage {

[MessageBody]

[MessageHeader]

}

Message

Defining a ContractDefining a Contract

DemoDemo

Hosting ServicesHosting Services

public class Service :

INuggetAccess

{ string[] GetTopics() { }

}

IIS

<%@ ServiceHost Service='Service' %>

NuggetAccessService.svc

MyApp.exe

ServiceHost host =

new ServiceHost();

host.Open();

References

ServiceHostServiceHost is the key class for hosting is the key class for hostingNeeds manual steps in your host applicationNeeds manual steps in your host application

Automatically done by IIS when provided with a Automatically done by IIS when provided with a .svc .svc filefile

IIS handles additional transports in V7.0IIS handles additional transports in V7.0

Hosting a ServiceHosting a Service

DemoDemo

BindingsBindings

'Service''Client'

Message Message

Transactions

Reliability

Security

Transactions

Reliability

Security

Channels

Configuration

Configuration

Configuration

Transport Channel (HTTP, TCP, etc)Configuration

BindingsBindingsBinding

Transactions

Reliability

Security

Channels

Configuration

Configuration

Configuration

Transport Channel (HTTP, TCP, etc)Configuration

Creates a configured set of channelsCreates a configured set of channelsStandard bindings in the frameworkStandard bindings in the framework

Build your own custom bindings out of new/existing Build your own custom bindings out of new/existing channelschannels

Standard Framework BindingsStandard Framework Bindings

Pre-built set in the Pre-built set in the frameworkframework

WS-I Basic ProfileWS-I Basic Profile

WS-* on HTTPWS-* on HTTP

TCPTCP

Named PipesNamed Pipes

MSMQMSMQ

PeerPeer

Configure/code your own Configure/code your own as a ‘custom’ bindingas a ‘custom’ binding

Binding

Transactions

Reliability

Security

Channels

Configuration

Configuration

Configuration

TransportConfiguration

Configuring a BindingConfiguring a Binding

DemoDemo

Securing Message ExchangesSecuring Message Exchanges

Transfer SecurityTransfer Security

AuthenticationAuthentication

PrivacyPrivacy

IntegrityIntegrity

Secure the transport or secure the messageSecure the transport or secure the message

AuthorisationAuthorisation

PrincipalPermissionPrincipalPermission attribute attribute

More flexible More flexible OperationRequirement OperationRequirement

Complete custom claims processing via XSIComplete custom claims processing via XSI

AuditingAuditing

Client

Message

Service

Securing Message ExchangesSecuring Message Exchanges

ScenarioScenario

Reliable Messaging (!= Queues)Reliable Messaging (!= Queues)

Client and Service running at the same timeClient and Service running at the same time

Can do exactly once, in orderCan do exactly once, in order

Can control the amount of ‘buffering’Can control the amount of ‘buffering’

Using WS-ReliableMessagingUsing WS-ReliableMessaging

Client Service

Message 1

Intermediary

Ack: Msg1

Message 2

Instancing, Concurrency, SessionsInstancing, Concurrency, Sessions

Service classes can be instantiatedService classes can be instantiated

Singleton, per-call, per-session, shareableSingleton, per-call, per-session, shareable

Service code can be eitherService code can be either

Single-threaded, re-entrant or multi-threadedSingle-threaded, re-entrant or multi-threaded

Client

Service

Singleton

Message B

Message C

Message A

Instancing, Concurrency, SessionsInstancing, Concurrency, Sessions

Service classes can be instantiatedService classes can be instantiated

Singleton, per-call, per-session, shareableSingleton, per-call, per-session, shareable

Service code can be eitherService code can be either

Single-threaded, re-entrant or multi-threadedSingle-threaded, re-entrant or multi-threaded

Client

Service

Single Call

Single Call

Single Call

Message B

Message C

Message A

Instancing, Concurrency, SessionsInstancing, Concurrency, Sessions

Service classes can be instantiatedService classes can be instantiated

Singleton, per-call, per-session, shareableSingleton, per-call, per-session, shareable

Service code can be eitherService code can be either

Single-threaded, re-entrant or multi-threadedSingle-threaded, re-entrant or multi-threaded

Client

Service

Per Session

Message B

Message Asession

Per SessionMessage C

Reliable Messaging & SessionsReliable Messaging & Sessions

ScenarioScenario

Transactional MessagingTransactional Messaging

Client ServiceMessage

WS-AT, OleTx

Distributed

Transaction

Coordinator

Queued Messaging (== Queues)Queued Messaging (== Queues)

Client and Service can have different lifetimesClient and Service can have different lifetimes

Relies on the MSMQ transportRelies on the MSMQ transport

Transactional, secure, in-order, etcTransactional, secure, in-order, etc

Client ServiceMessage

Queue

MessageMessageMessageMessage

Queued MessagingQueued Messaging

ScenarioScenario

© 2006 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only.MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.

Recommended