windows communication foundation
DESCRIPTION
Microsoft WCF bookTRANSCRIPT
-
Windows Communication Foundation(formerly known as Indigo)
-
AgendaIntroductionWCF ConceptsProgramming WCF
-
Introduction
-
What is WCF?Part of the new WinFX platformNew, unified programming model for building connected applications on the Windows platformScale-invariantPay-as-you-go model
-
What is WCF?Platform for advanced Web Services Standards basedBuilding secure, reliable, transacted solutionsBest choice for implementing SOA applicationsIntegration across platformsClient- or server-side component
-
What is WCF?Unified Technologies ASMX Web ServicesWeb Service Enhancements, WSE.NET RemotingEnterprise Services, COM+MSMQInteroperability with existing investments
-
Meta informationHistoryPublicly previewed at PDC 2003Currently in beta 2Due for release in 2006Supported platformsWindows XP SP2Windows Server 2003Windows VistaWindows Server LonghornRequirements.NET Framework 2.0
-
WCF Concepts
-
Clients and ServicesClientService
Message
-
EndpointsThe unit of communicationThe ABC of WCFAddress where to exposeBinding how to exposeContract what to expose Defined in code or in configurationService
Message
-
Configuration
-
AddressDefines where a service is locatedSpecifies a URI where the service is locatedRelative or absoluteAddress consist ofSchemeHTTP, TCP, Named pipes, MSMQMachine[Port]PathExamples http://www.mystore.com/StoreFrontnet.tcp://mycomputer:9000/StoreFront
-
BindingDescribes how a service communicatesSpecifies set of binding elementsTransport; http, tcp, np, msmqEncoding format; text, binary, MTOM, ...Security requirementsReliable session requirementsTransaction requirementsSet of predefined standard bindingsCan be customizedCustom binding
-
Predefined bindings
Binding Interop Security Session Transactions Duplex basicHttpBinding Basic Profile 1.1TransportNon/an/awsHttpBinding WSMessageYesYesn/awsFederationBinding WS-FederationMessageYesYesYeswsDualHttpBinding WSMessageYesYesYesnetTcpBinding .NETTransportYesYesYesnetNamedPipeBinding .NETTransportYesYesYesnetMsmqBinding .NETTransportYesYesNonetPeerTcpBinding PeerTransportNoNoYesmsmqIntegrationBinding MSMQTransportNoYesNo
-
Configuration
-
ContractDefines what a service communicateSupports contract first or code first modelsContract first = interfacesMay use WSDL first as wellMessage vs. RPC style APIsService contractData contract
-
Service ContractsDescribes what a service doesMaps CLR types to WSDL[ServiceContract] defines the service contract[OperationContract] specifies operationsOne-way, request-reply, duplex MEPs, Sessions, Faults
-
A Service Contract
-
Data ContractDefines data structuresMaps CLR types to XML Schema[DataContract] specifies types[DataMember] specifies members Can be applied to private fields!
-
A Data Contract
-
BehaviorModifies or extends service or client runtime behavior ExamplesInstancing; Singleton, PrivateSession, SharedSession, PerCall Concurrency; Multiple, Reentrant, Single Throttling; connections, threadingMetadata customizationTransactions; AutoEnlist, Isolation, AutoComplete
-
Features SummaryAddress
Binding
Behavior
Contract
HTTP TransportTCPTransportNamedPipe TransportMSMQ TransportCustom TransportWS-Security ProtocolWS-RM ProtocolWS-Coord ProtocolDuplex ChannelCustom Protocolhttp://...net.tcp://...net.pipe://...net.msmq://...xxx://...ThrottlingBehaviorMetadata BehaviorError BehaviorCustom BehaviorInstancing BehaviorConcurrency BehaviorTransaction BehaviorSecurity BehaviorRequest/ ResponseOne-WayDuplexnet.p2p://...PeerTransportExternally visible, per-endpointOpaque, per-service,endpoint, or operation
-
RuntimeFormats, sends and receives messagesDispatches message to service operationAttributes, code and config are used to dynamically create a ServiceHost instancePrecedence: attribute, code, config
-
HostingASP.NET, .SVC format ()IIS 6: HTTP transport onlyIIS 7: All transportsWindows Activation Service, WASSame process management, health, and activation features as IIS without requiring a Web server.Self hosted, ServiceHostHosted in any CLR appDomainAll transportsIIS/WAS is the expected hosting model
-
MetadataExposed through WS-MetadataExchange EndpointsEnabled by default, can be disabled through behaviorConsumed using svcutil.exeGenerates code and configuration
-
DiagnosticsLoggingRequest and reply messagesTracingEnd-to-end trace of [correlated] eventsWMI eventsPerformance monitor countersEvent Log
-
Programming WCF
-
Building a WCF applicationApplication DesignServiceDefine ContractsImplement ContractsDefine EndpointsHost & Run ServiceClientGenerate Proxy from MetadataImplement & Run Client
-
Application Design
-
Application DesignOrder ServiceAdmin ClientOrder Client
-
Define ContractsService ContractsOrder client and admin API (duplex)
Data ContractsShopping cartItem
-
Implementing ContractsOne class per service interfaceClass may specify ServiceBehavior attributes
-
Defining EndpointsOne per service interfacewsHttpBinding, wsHttpDualBindingRember WCF ABC!Can be specified in code or configurationConfiguration is to be preferred
-
Endpoint Configuration
-
HostingSelf hosted in console applicationOne ServiceHost per ServiceType
-
Generating ProxiesGenerated dynamically from servicesvcutil.exe Note: service must be runningGenerate proxy and configuration filessvcutil http://localhost:8000/StoreFront /out:proxy.cs /config:app.configProxy generator add-in for Visual Studio
-
Implementing the ClientClient configuration obtained from generated codeStatless server callsRemember to close proxy correctly
-
Implementing the Admin ClientAgain, client configuration obtained from generated codeDuplex callback interface implementationRequires stateful connection!
-
Summary
-
Mappings to SOABoundaries are ExplicitService and data contractsServices are autonomousIndependent deployment, versioning, and securityShare Schema, not ClassIntegration based on message formats and exchange patterns, not classes and objectsPolicy-based compatibilityService compatibility based on policy assertions (behaviors)
-
SummaryWCF is the next generation Web Services from MicrosoftLearn your ABCDefine contracts firstSupports building SOABut not limited to only thatUnified programming model
-
ReferencesWCF Official Web Sitehttp://windowscommunication.net/Default.aspx?tabindex=0&tabid=1WCF on MSDNhttp://msdn.microsoft.com/webservices/indigo/default.aspx