Windows Communication Foundation (WCF) is Microsoft’s dynamic technology for allowing autonomous software to communicate. Superseding earlier technologies such as COM/DCOM, .NET Remoting, ASP.NET Web Services, and the Web Services Enhancements for .NET, WCF provides a single solution that is designed to always be the best way to exchange data among software entities. It also provides the infrastructure for developing the next generation of Web Services, with support for the WS-* family of specifications, and a new serialization system for enhanced performance. In the 3.5 release, WCF has been expanded to include support for REST, JSON, and Syndication (RSS and Atom) services, further broadening the possibilities for what can be done. For information technology professionals, WCF supplies an impressive array of administration tools that enterprises and software vendors can use to reduce the cost of ownership of their solutions without writing a single line of code. Most important, WCF delivers on the promise of model-driven software development with the new software factory approach, by which one can iteratively design solutions in a modeling language and generate

executables from lower-level class libraries.

Windows Communication Foundation 3.5 Unleashed is designed to be the essential resource for software developers and architects working with WCF. The book guides readers through a conceptual understanding of all the facilities of WCF and provides step-by-step guides to applying the technology to practical problems.

As evangelists at Microsoft for WCF, WF, and CardSpace, Craig McMurtry, Marc Mercuri, Nigel Watling, and Matt Winkler are uniquely positioned to write this book. They had access to the development team and to the product as it was being built. Their work with enterprises and outside software vendors has given them unique insight into how others see the software, how they want to apply it, and the challenges they face in doing so.

--Gives you nearly 100 best practices for programming with WCF

--Provides detailed coverage of how to version services that you will not find anywhere else

--Delves into using WCF together with Windows Workflow Foundation (WF) and Windows CardSpace

--Provides detailed coverage of the new high-performance data contract serializer for .NET

--Walks you through creating secure, reliable, transacted messaging, and how to understand the available options

--Introduces you to federated, claims-based security and shows you how to incorporate SAML and WS-Trust security token services into your architecture

--Provides step-by-step instructions for how to customize every aspect of WCF

--Shows you how to add behaviors, communication channels, message encoders, and transports

--Presents options for implementing publish/subscribe solutions

--Gives clear guidance on peer-to-peer communications with WCF

"synopsis" may belong to another edition of this title.

About the Author:

Matt Winkler is a senior Program Manager in Microsoft’s Connected Systems Division, where he focuses on building the visual designer for WF. Previously he was the Technical Evangelist for WF, focusing on driving adoption among software developers around the world. Based in Redmond, Matt spends his non-work time reading more tech books and chasing around his two children.

The Windows Communication Foundation, which was code-named Indigo, is a technology that allows pieces of software to communicate with one another. There are many other such technologies, including the Component Object Model (COM) and Distributed Component Object Model (DCOM), Remote Method Invocation (RMI), Microsoft Message Queuing (MSMQ), and WebSphere MQ. Each of those works well in a particular scenario, not so well in others, and is of no use at all in some cases. The Windows Communication Foundation is meant to work well in any circumstance in which a Microsoft .NET assembly must exchange data with any other software entity. In fact, the Windows Communication Foundation is meant to always be the very best option. Its performance is at least on par with that of any other alternative and is usually better; it offers at least as many features and probably several more. It is certainly always the easiest solution to program.

Concretely, the Windows Communication Foundation consists of a small number of .NET libraries with several new sets of classes that it adds to the Microsoft .NET Framework class library, for use with version 2.0 and later of the .NET Common Language Runtime. It also adds some facilities for hosting Windows Communication Foundation solutions to the 5.1 and later versions of Internet Information Services (IIS), the web server built into Windows operating systems.

The Windows Communication Foundation is distributed free of charge as part of a set that includes several other technologies, including the Windows Presentation Foundation, which was code-named Avalon, Windows CardSpace, which was code-named InfoCard, and the Windows Workflow Foundation. Prior to its release, that group of technologies was called WinFX, but it was renamed the .NET Framework 3.0 in June 2006. Despite that name, the .NET Framework 3.0 and 3.5 is still primarily just a collection of classes added to the .NET Framework 2.0 for use with the 2.0 version of the .NET Common Language Runtime, along with some enhancements to the Windows operating system, as shown in Figure I.1.

Figure I.1The .NET Framework 3.0.

You can install the .NET Framework 3.0 and 3.5 on Windows XP Service Pack 2, Windows Server 2003, and Windows Server 2003 R2. The runtime components are preinstalled on Windows Vista. On Windows Server 2008 you can add the .NET Framework 3.0 via the Application Server Foundation role service. Only a very small number of features of the .NET Framework 3.0 are available exclusively on Windows Vista and later operating systems.

The .NET Framework 3.5 builds incrementally on top of .NET Framework 3.0. Features relevant to this book include web protocol support for building Windows Communication Foundation services, including AJAX, JSON, REST, POX, RSS and ATOM, workflow-enabled services and full tooling support in Visual Studio 2008. During development, .the NET Framework 3.5 was factored into "red" bits and "green" bits. The red bits were features from .NET Framework 3.0 and the goal was to provide Service Pack levels of compatibility. All the code that worked in 3.0 will work in 3.5. The green bits provide new, additional functionality. Again, the addition of an assembly containing new functionality should have no effect on existing code. The bottom line is that all the code in this book will work with .NET Framework 3.5 and all the code in this book (except the new features introduced in .NET Framework 3.5) should work in .NET Framework 3.0.

This book does not serve as an encyclopedic reference to the Windows Communication Foundation. Instead, it provides the understanding and knowledge required for most practical applications of the technology.

The book explains the Windows Communication Foundation while showing how to use it. So, typically, each chapter provides the precise steps for building a solution that demonstrates a particular aspect of the technology, along with a thorough explanation of each step. Readers who can program in C#, and who like to learn by doing, will be able to follow the steps. Those who prefer to just read will get a detailed account of the features of the Windows Communication Foundation and see how to use them.

To follow the steps in the chapters, you should have installed any version of Visual Studio 2005 or 2008 that includes the C# compiler. Free copies are available at http://msdn.microsoft.com/vstudio/express/. You should also have IIS, ASP.NET, and MSMQ installed.

The .NET Framework 3.0 or 3.5 is required, as you might expect. You can download them from http://www.microsoft.com/downloads/. The instructions in the chapters assume that all the runtime and developer components of the .NET Framework 3.0 or 3.5 have been installed. It is the runtime components that are preinstalled on Windows Vista and that can be added via the Server Manager on Windows Server 2008. The developer components consist of a Software Development Kit (SDK) and two enhancements to Visual Studio 2005. The SDK provides documentation, some management tools, and a large number of very useful samples. The enhancements to Visual Studio 2005 augment the support provided by IntelliSense for editing configuration files, and provide a visual designer for Windows Workflow Foundation workflows. These features are included in Visual Studio 2008.

To fully utilize Windows CardSpace, which is also covered in this book, you should install Internet Explorer 7. Internet Explorer 7 is also available from http://www.microsoft.com/downloads.

Starting points for the solutions built in each of the chapters are available for download from the book's companion page on the publisher's website, as well as from http://http://www.cryptmaker.com/WindowsCommunicationFoundationUnleashed. To ensure that Visual Studio does not complain about the sample code being from a location that is not fully trusted, you can, after due consideration, right-click the downloaded archive, choose Properties from the context menu, and click on the button labeled Unblock, shown in Figure I.2, before extracting the files from the archive.

Figure I.2Unblocking a downloaded source code archive.

Note that development on the Vista operating system is supported for Visual Studio 2008 and for Visual Studio 2005 with the Visual Studio 2005 Service Pack 1 Update for Windows Vista. This update is also available from http://www.microsoft.com/downloads. Developers working with an earlier version of Visual Studio 2005 on the Vista operating system should anticipate some compatibility issues. To minimize those issues, they can do two things. The first is to disable Vista's User Account Protection feature. The second is to always start Visual Studio 2005 by right-clicking on the executable or the shortcut, selecting Run As from the context menu that appears, and selecting the account of an administrator from the Run As dialog.

As with the .NET Framework 3.5 when compared to the .NET Framework 3.0, this book is very similar to its predecessor. Changes include the addition of Visual Studio 2008 support and Chapter 3, "Data Representation and Durable Services," now covers durable services. The chapters on Windows CardSpace show the updated user interface and cover new features. Chapter 18, "Representational State Transfer and Plain XML Services," on REST and POX, includes details on the new syndication and JSON APIs. Perhaps the most significant change is a complete rewrite of Chapter 6, "Using the Windows Communication Foundation and the Windows Workflow Foundation Together," covering the much improved integration between Windows Workflow Foundation and the Windows Communication Foundation.

A particular debt of gratitude is owed to John Lambert for reviewing the drafts. No one is better qualified to screen the text of a book on a programming technology than an experienced professional software tester. Any mistakes in the pages that follow are solely the fault of the writers, however.

The authors are especially grateful for the support of their wives. They are Marta MacNeill, Kathryn Mercuri, Sylvie Watling, and Libby Winkler. Matt, the only parent so far, would also like to thank his daughter, Grace.