Robert MacLeanTechnology SpecialistBB&D
WCF Made Easy with .NET 4 & Windows Server AppFabric
3
Who am I?
Robert MacLeanMicrosoft ALM MVPMicrosoft ALM RangerProud Community Lead
Information WorkerS.A. Architect
www.sadev.co.za@rmaclean
4
Overture
Level 300What is new in WCF 4 to make it easy?What is AppFabric?WCF + AppFabric = Easy
Warning: Excessive use of implicit, explicit and angle brackets ahead
5
The big picture of WCF 4
What is new?Configuration defaults, default endpointsWorkflow ServicesHigh performance tracing with ETWNew features for REST-based servicesQueued messaging enhancementsNew protocols
Basic Profile 1.2WS-Discovery and DiscoveryService
RouterServiceNew DataContractResolver, extensibility
6
My thoughts on WCF
WCF is hardCompared to ASMXConfiguration
BindingsEndpoints
7
Building ServicesASMX
Write class, add attribute
Expose web methods
Just work with POCO“old” WCF
Interface + Attribute
Write class, add attribute
Data Contracts
Config
Config Fixes
WCF Sexy
Interface + Attribute
Write class, add attribute
Just work with POCO
WCF Sexy
Demo
9
Protocol Mappings
<protocolMapping> <clear /> <add scheme="http" binding="basicHttpBinding" bindingConfiguration="" /> <add scheme="net.tcp" binding="netTcpBinding" bindingConfiguration="" /> <add scheme="net.pipe" binding="netNamedPipeBinding" bindingConfiguration="" /> <add scheme="net.msmq" binding="netMsmqBinding" bindingConfiguration="" /> </protocolMapping> Start with this
Eg: http://demo
This is your binding
Default binding config!!!
10
Default Endpoints & Hosts
Self HostSupply base address via code or configExplicit: ServiceHost.AddDefaultEndPoints() Implicit: ServiceHost.Open()
IISBase address is .svc endpointHTTP protocol is provided by defaultProtocols can be added in IIS Manager
11
Are Default Endpoints A Good Thing?
Designed to cater for the current majorityYou may be special
Quota issuesWSHttp or WebHttpMEXLimiting which contracts on which protocols
You can override in machine.config (bad – mostly) or app.config (better – mostly)
12
Refined Default Config<system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /></system.serviceModel>
13
POCO BEFORE .NET 3.5 SP1[DataContract]public class User{ [DataMember] public string FirstName { get; set; } [DataMember] public string LastName { get; set; } [DataMember] public string Username { get; set; } public string Password { get; set; } // do not share}
Explicit
14
POCO FROM .NET 3.5 SP1public class User { public string FirstName { get; set; } public string LastName { get; set; } public string Username { get; set; } [IgnoreDataMember] public string Password { get; set; } // do not share}
IMPLICIT
15
Been to my other talks?
16
A rose by any other name…
Windows Server AppFabric Contains two key componentsHosting
EndPoint, Windows App Server Extensions, DublinCaching
VelocityNot to be confused with Azure AppFabric
17
N.B. AppFabric
Requires .NET 4 on ServerApplications for not need .NET 4, depends on features
Standalone download or Web Platform InstallerHigh Availability is only in Windows Server 2008 Enterprise & Data Centre
18
Windows Server AppFabric Architecture
Windows Activation Services
.NET Framework SQL Server Tooling
IIS
Windows Server AppFabric
WCF
WF
ASP.
NET
Visu
al
Stud
io
SCO
M
Pow
erSh
ell
Logging
Event Tracing for Windows
Pers
isten
ce
Mon
itorin
g
Cach
ing
AppFabric + WCF = Easy
Demo
20
Summary
WCF 4 can be as easy as ASMXFor majority of simple scenariosAbility to break the mould is there
AppFabric & WCFThe tools to configure and manage servicesScalable, manageable solution for hosting services on Windows
22
Resources
www.microsoft.com/teched
Sessions On-Demand & Community Microsoft Certification & Training Resources
Resources for IT Professionals Resources for Developers
www.microsoft.com/learning
http://microsoft.com/technet http://microsoft.com/msdn
Learning
SMS [ Your Name ] and the word “AppServer” to 41491Need more Information?
Complete an evaluation via CommNet and Tag to win amazing prizes!
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED
OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.