Required Slide SESSION CODE: ASI310 WCF Made Easy with Microsoft .NET Framework 4 and Windows Server AppFabric Michele Leroux Bustamante Chief Architect, IDesign Chief Security Architect, BiTKOO Microsoft Regional Director
Michele Leroux Bustamante Chief Architect, IDesign(www.idesign.net) Chief Security Architect, BiTKOO(www.bitkoo.com) Microsoft Regional Director, MVP Connected Systems Published Author:Dev Connections Magazine (Federated Security Column), MSDN, CoDe Magazine, Microsoft whitepapers Learning WCF (O’Reilly 2007/2009) Speaker:Tech Ed, PDC, Dev Connections, NDC, etc. Blogs: www.michelelerouxbustamante.com, www.learningwcf.com
Agenda • What’s new in WCF 4? • Default endpoints • Default bindings and behaviors • Recommendations for defaults • What is Windows Server AppFabric? • Simplified WCF configuration and troubleshooting
WCF 4 • WCF 4 released April 2010 • Part of Visual Studio 2010 and .NET Framework 4 • WCF 4 enhancements • Configuration defaults, default endpoints • High performance tracing with ETW • New features for REST-based services • Queued messaging enhancements • WCF Workflow Services • New protocols • Basic Profile 1.2 • WS-Discovery and DiscoveryService • RouterService • New DataContractResolver, extensibility Our focus + AppFabric
ASMX and WCF 4 • ASMX • Generate a web service class, modify namespace • Expose web methods • Use complex types, serialize public members • Generate web reference (proxy) • Create proxy and call methods • WCF 4 • Generate a service interface and class, modify namespace • Expose service operations • Use complex types, serialize public members (POCO) • Generate service reference (proxy) • Create proxy and call operations
WCF Simplified DEMO
ASMX Equivalence In WCF 4 • POCO types introduced with .NET Framework 3.5 SP1 • No need to produce data contracts or serializable types for WCF • WCF 4 introduces features to simplify the ASMX equivalent path • Protocol mappings • Default endpoints • Default bindings and behaviors
Protocol Mappings • Protocol mappings match • Protocol scheme • Binding • Binding configuration (default “”) • Binding defaults are provided by the service model • NOTE: See Machine.config.comments
Default Endpoints • Generate one endpoint per base address, per contract • Only one base address per protocol (http, net.tcp, net.pipe, net.msmq) • IIS-hosting • Base address is .svc endpoint • HTTP protocol provided by default • Protocols added in IIS Manager • Self-hosting • Supply base address per protocol in config or code • Explicitly call ServiceHost.CreateDefaultEndpoints() • MetadataExchange endpoint added by default • Supports proxy generation
Default Endpoints DEMO
Default Endpoints • Feel good ASMX-equivalent experience • No need to touch configuration • Administer protocols via IIS Manager • However… • Default bindings usually require some tweaking • BasicHttpBinding is pretty close, could be quota issues • Might want to map HTTP to WSHttp or WebHttp • Developer ultimately has to come up with the right binding configuration • Sometimes want/need more control over endpoints • Which contracts exposed over multiple protocols • Suppressing metadata endpoints (Look ma! I can do WCF!)
Default Bindings and Behaviors • Supply better defaults in the machine or application config • Protocol mappings • Map http protocol to WS2007HttpBinding or WebHttpBinding • And then use default binding • Binding configurations • Provide new defaults for each binding • Behaviors • Provide a default service behavior • All services must share settings
Default Bindings and Behaviors • Heavily influenced by security model • Common scenarios: • Classic Intranet • Anonymous over HTTP • Anonymous over HTTPS/SSL • UserName over SSL • UserName for Certificate • Trusted subsystem / Windows or Certificate • Federated identity
WCF 4 Templates http://wcf4templates.codeplex.com DEMO
Recommendations: Endpoints, Bindings and Behaviors • Automatic endpoints, default bindings and default behaviors are very useful for early prototyping and productivity • You will necessarily make adjustments for protocol requirements • Unless all you want is ASMX • You will control endpoints • Visibility • Not all contracts may be exposed over all protocols • You may choose a few default bindings per protocol • Configure in application config (visibility) • Allow default configuration to be used per endpoint • You may be able to share service behaviors across services • If security behavior is equivalent
Configuring WCF Services • For developers • Easier with default endpoints, default bindings, default behaviors • Easier with templates illustrating recommended practices • For IT • How does IT know to adjust relevant settings? • What tools can they use?
Troubleshooting WCF Services • For developers • Exceptions during development • Enable trace in configuration • Test again • Search through trace logs (cumbersome) • Difficult to resolve problems involving multiple service calls • For IT • File-based logs inefficient • Performance counters are heavy • May not be able to reproduce issue • Need a way to control monitoring and diagnostic settings • Must not affect system performance
Windows Server AppFabric • Technologies for deploying, managing and scaling applications deployed on Internet Information Services (IIS) 7 • Manage and monitor services and workflows via IIS Manager and Windows PowerShell (formerly codename “Dublin”) • Distributed in-memory cache (formerly codename “Velocity”) • AppFabric and WCF • Empowers the IT role • Through dashboard can access necessary WCF configuration • Provides immediate visibility into application metrics • Enable monitoring and diagnostics • Leverages high performance ETW tracing • View relevant execution statistics
Configuring WCF and WF Settings • Per machine, disable metadata browsing • Per application, enable as desired • Enable or disable metadata endpoints
Configuring WCF and WF Settings • Per machine, enable Health Monitoring • Per application, use Troubleshooting as needed • Enable message logging as needed • NOTE: can customize profiles!
Configuring WCF and WF Settings • Per machine, disable auto-start to conserve resources • Per application, likely to opt-in depending on availability requirements • Required for services hosted with the Windows Azure AppFabric Service Bus
Configuring WCF and WF Settings • Per machine, set defaults for throttling • Per application, may require adjustments for load • Throttles are very important to WCF service scalability and throughput! • WCF 4 throttling defaults are much better
Configuring WCF and WF Settings • Per machine, not likely to set certificate • Per web site, good place to set default cert for site • Per application, may adjust per application
Summary • WCF can be as easy as ASMX • If you don’t need additional features • WCF 4 simplifies configuration • Reduced footprint • Centralize defaults (and customize them) • AppFabric provides useful administrative and troubleshooting tools • IT administrator can configure appropriate settings • Developers can troubleshoot code locally, more easily • Easier to track down issues on production servers
Resources • Learning WCF • Michele Leroux Bustamante, O’Reilly 2007/2009 • Second Edition in progress, 2010 • Book blog: www.learningwcf.com • My Blog: www.michelelerouxbustamante.com • Look for session resources on my blog!
Required Slide Speakers, please list the Breakout Sessions, Interactive Sessions, Labs and Demo Stations that are related to your session. Related Content • ASI201 Intro to Workflow Services and Windows Server AppFabric • ASI313 Windows Server AppFabric Caching: What It Is and When You Should Use It • ASI201 Intro to Workflow Services and Windows Server AppFabric • ASI203 Understanding the Microsoft Application Server: AppFabric, WF, WCF, and More • TO70E7 Debug WCF Endpoints like a Freaking Genius • TD1064 So You’re Just Getting Into WCF • TE7322 What's New in WCF/WF 4.0 and AppFabric • TLC-05 Windows Server AppFabric : WF and WCF
Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. ASI Track Resources • Website – www.Microsoft.com/WindowsAzure/AppFabric • MSDN Developer Center – http://msdn.microsoft.com/en-us/azure/netservices.aspx • Blog – http://blogs.msdn.com/b/netservices/ • Twitter – http://twitter.com/azure_appfabric • Website – http://www.microsoft.com/biztalk/ • Website – http://msdn.microsoft.com/biztalk/ • Blog – http://blogs.msdn.com/biztalk_server_team_blog • Blog – http://www.biztalkblogs.com/ • Application Infrastructure Virtual Launch Event – www.appinfrastructure.com • AppFabric on Microsoft.com – http://www.microsoft.com/appfabric • Developer Center – http://msdn.microsoft.com/appfabric
Required Slide Resources Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet • http://microsoft.com/msdn
Required Slide Complete an evaluation on CommNet and enter to win!
Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st http://northamerica.msteched.com/registration You can also register at the North America 2011 kiosk located at registrationJoin us in Atlanta next year
© 2010 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.