Essential Windows Communication Foundation: For .NET Framework 3.5 (Microsoft .NET Development Series)

Paperback (Print)
Buy New
Buy New from BN.com
$32.06
Used and New from Other Sellers
Used and New from Other Sellers
from $1.99
Usually ships in 1-2 business days
(Save 96%)
Other sellers (Paperback)
  • All (20) from $1.99   
  • New (7) from $27.73   
  • Used (13) from $1.99   

Overview

“Whether this is the first time or the fifty-first time you’re using WCF, you’ll learn something new by reading this book.”

--Nicholas Allen, Program Manager, Web Services, Microsoft

Windows Communication Foundation (WCF) is the easiest way to produce and consume Web services on the Microsoft platform. With .NET 3.5, WCF has been extensively revamped--and Visual Studio 2008 gives developers powerful new tools for utilizing it. Essential Windows Communication Foundation shows developers exactly how to make the most of WCF with .NET 3.5 and Visual Studio 2008.

Drawing on extensive experience working with early adopters, three Microsoft insiders systematically address the topics developers ask about WCF. The authors approach each subject with practical advice and present best practices, tips, and tricks for solving problems. Throughout, you’ll find detailed explanations, solutions for the “pain points” of WCF development, and an extensive collection of reusable code examples. Coverage includes

  • Using WCF contracts to define complex structures and interfaces
  • Understanding WCF’s channel stacks and channel model architecture
  • Configuring the WCF communication stack to use only the protocols you need
  • Using standard and custom service behaviors to manage concurrency, instances, transactions, and more
  • Serializing data from .NET types to XML Infosets and representing Infosets “on the wire”
  • Hosting WCF services via IIS, managed .NET applications, and Windows Activation Services
  • WCF security, in depth: authentication; transport and message-level security; and Internet and intranet scenarios
  • Improving reliability: exception handling, diagnostics, and more
  • Workflow services: new integration points between WCF 3.5 and Windows Workflow Foundation
  • Building client-to-client, peer network-based applications
  • Utilizing WCF for non-SOAP Web services: AJAX and JSON examples and .NET 3.5 hosting classes

Microsoft’s Steve Resnick, Richard Crane, and Chris Bowen are technology experts at the Microsoft Technology Center in Boston. They specialize in helping customers improve their technical agility by applying WCF and related technologies. Resnick has specialized in Internet technologies and distributed computing at Microsoft since 1995. He is a frequent speaker at Microsoft events and is now technology director for the U.S. Microsoft Technology Centers. Crane has more than 15 years of experience in senior software development roles. He specializes in large-scale Web sites, distributed computing, transactional systems, and performance analysis. Bowen has been an architect and developer for more than 15 years at companies such as Monster.com and Staples and is co-author of Professional Visual Studio 2005 Team System.

Foreword xxv

Preface xxvii

Chapter 1: Basics 1

Chapter 2: Contracts 33

Chapter 3: Channels 91

Chapter 4: Bindings 111

Chapter 5: Behaviors 181

Chapter 6: Serialization and Encoding 241

Chapter 7: Hosting 287

Chapter 8: Security 315

Chapter 9: Diagnostics 375

Chapter 10: Exception Handling 403

Chapter 11: Workflow Services 423

Chapter 12: Peer Networking 459

Chapter 13: Programmable Web 503

Appendix: Advanced Topics 537

Index 553

Read More Show Less

Product Details

  • ISBN-13: 9780321440068
  • Publisher: Addison-Wesley
  • Publication date: 2/25/2008
  • Series: Microsoft .NET Development Series
  • Pages: 608
  • Product dimensions: 7.02 (w) x 9.25 (h) x 1.09 (d)

Meet the Author

Steve Resnick has worked at Microsoft since the mid-1990s, spanning architect, developer, and evangelist roles in the field. He specializes in Internet technologies, architecting and designing high-volume, high-value Web applications. Steve is the National Technology Director for the Microsoft Technology Centers in the United States, where he sets strategy and direction so that his team can solve the toughest customer challenges. He has worked with .NET since the beginning and is an expert in Web services, BizTalk, transaction processing, and related technologies. He holds a M.S. and B.S. in Computer Science from Boston University and University of Delaware, respectively.

Rich Crane is a Technical Architect at the Microsoft Technology Center in Waltham, Massachusetts. A software architect and engineer with more than 18 years of experience, Rich has spent the last six years helping customers architect and build solutions on the Microsoft platform. He has worked with numerous Microsoft products and technologies and is an expert in BizTalk, SQL Server, SharePoint, Compute Cluster Server, and of course Visual Studio and the .NET Framework. He has spoken at conferences and community events such as TechEd and Code Camp. He graduated Summa Cum Laude from Drexel University with a B.S. degree in Electrical and Computer Engineering.

Chris Bowen is Microsoft’s Developer Evangelist for the northeastern United States, specializing in development tools, platforms, and architectural best practices. Asoftware architect and engineer with 15 years of experience, Chris joined Microsoft after holding senior positions at companies such as Monster.com, VistaPrint, Staples, and IDX Systems, and consulting on Web presence and e-commerce projects with others. He is coauthor of Professional Visual Studio 2005 Team System (2006, WROX) and holds an M.S. in Computer Science and a B.S. in Management Information Systems, both from Worcester Polytechnic Institute.

Read More Show Less

Read an Excerpt

Essential WCFPreface

Windows Communication Foundation (WCF) is the unified programming model for writing distributed applications on the Microsoft platform. It subsumes the prior technologies of ASMX, .NET Remoting, DCOM, and MSMQ and provides an extensible API to meet a wide variety of distributed computing requirements. Prior to WCF, you needed to master each of those technologies to select the right approach for a particular distributed application requirement. WCF simplifies this considerably by providing a unified approach.

Rich, Chris, and I have each developed code with .NET from the beginning (circa 1999). We work at Microsoft in the field, helping customers use WCF to solve real-world problems. Our customers range from large multinational corporations to ISVs to Web startups. Each has different challenges, needs, and priorities that we individually address. We show them what's possible, recommend what works well, and steer clear of what doesn't. We have experience building distributed applications and leverage that experience in teaching others about WCF.

Our goal for this book is to present WCF in a way that can immediately be put to use by software developers. We cover the material in enough detail that you know how and why to use different features. We go a bit further in most cases, describing some of the subtleties in the framework, but not so far as to document the API.

The Blogosphere is rich with WCF details. Much of it comes from the .NET product team and much of it comes from other developers learning it along the way. We made extensive use of Blogs as source material. This book brings order to that repository by organizing it in a waythat can be easily consumed from your desk, sofa, or wherever you do your best reading. Who Should Read This Book?

We wrote this book for software developers who want to build distributed applications on the .NET platform. As fellow developers, we know the importance of solid advice and clear examples on how to use new technology. We've trolled the Blogosphere, scoured internal Microsoft e-mail aliases, and wrote plenty of code to provide you with the best examples for doing the things you need to do.

Architects who need to understand WCF will also benefit from this book. The chapters covering basics, bindings, channels, behaviors, hosting, workflow, and security describe important aspects of designing and implementing services with WCF. Reading the two to three page introductions in each of these chapters may be the best way to get the 50,000-foot view of the technology.

Our goal in writing this book is to shorten your learning curve for WCF. We describe and demonstrate how to do the common tasks, addressing the basics as well as advanced topics. Throughout the book, we approach topics as a series of problems to be solved. Rather than documenting the API, we describe how to use WCF to accomplish your goals.

Prerequisites for this book are modest. If you're interested in WCF, you probably already have grounding in .NET. You're probably competent in C# or Visual Basic, or at least you were at one point. And, of course, you probably know your way around Visual Studio. So we're assuming that you're can write decent .NET code and are motivated to make the best use of your time in becoming proficient in WCF. Installation Requirements

WCF is a key component of the Microsoft .NET Framework 3.x. WCF was first released with .NET 3.0 and has been enhanced in .NET 3.5. The delta between the two releases is modest: enhancements for non-SOAP Web services, integration between WCF and WF, and a healthy service pack. This book covers .NET 3.5. Unless there's a reason to use an older release, this is the clear recommendation.

.NET is packaged in two forms: the redistributable runtime libraries and the software development kit (SDK). The runtime libraries are meant for target machinesmdthose machines that are not for development. This includes testing, staging, and production environments. The SDK is meant for your development machines. The SDK contains code samples, documentation, and tools that are useful for development. Each of these .NET packages, the runtime and SDK versions, can be downloaded from Microsoft's MSDN site at http://msdn2.microsoft.com/en-us/netframework/default.aspx. The .NET 3.5 SDK also ships with Visual Studio 2008.

The Microsoft .NET Framework 3.5 can be installed on Windows XP SP2, Windows Vista, Windows Server 2003, and Windows Server 2008.Organization

We don't expect you to read the book cover to cover. If you're new to WCF, you may want to read and try the samples in Chapter 1, "Basics," first. Following that, each subsequent chapter covers a major feature set of WCF. We include a few introductory pages in each chapter to describe the motivation and some design goals, and then we cover subtopics within the chapter.

Chapter 1, "Basics," is where we cover the basics of building and consuming WCF services. We discuss and demonstrate how to implement different types of interfaces and why you may choose each. By the end of this chapter, you'll be able to produce and consume services using the WCF.

Chapter 2, "Contracts," covers the three primary types of contacts in WCF: service contracts, data contracts and message contracts. Each of these enables you to define complex structures and interfaces in code. Data contracts map .NET types to

Chapter 3, "Channels," covers channels and channel stacks. The channel model architecture is the foundation on which the WCF communication framework is built. The channel architecture allows for the sending and receiving of messages between clients and services. Channel stacks can be built to exactly match your needs.

Chapter 4, "Bindings," describes how to configure the communication stack to use exactly the protocols you need. For instance, if you're communicating within an enterprise and won't be crossing firewalls, and you need the fastest performance, a binding named netTcpBinding will give you best results. If you're looking to communicate with every last Web client out there, then HTTP and text encoded

basicHttpBinding is the way to go. A binding is synonymous with a preconfigured channel stack.

Chapter 5, "Behaviors," covers service behaviors. In WCF, behaviors are the mechanism for affecting service operation outside of the actual message processing. Everything that is done after a message is received but before it is sent to the service operation code is the domain of behaviors. In WCF, this is where concurrency and instance management is handled, as well as transactional support. This chapter also demonstrates how to build custom behaviors for additional service control.

Chapter 6, "Serialization and Encoding," describes the process by which data is serialized from a .NET Type (class) to an

Chapter 7, "Hosting," describes the various options in hosting a WCF service. The most common environment, IIS, is described, but it is by far not the only option. WCF services can be hosted in Managed .NET applications, Windows Activation Services, or any other .NET program. This chapter discusses the options and techniques for hosting.

Chapter 8, "Security," is a large chapter and covers the multitude of security options. Different authentication schemes are discussed and demonstrated. Transport and message level security are compared, with examples of each. Intranet and Internet scenarios are also described.

Chapter 9, "Diagnostics," describes how to use the built-in trace facilities in .NET to capture WCF events. Trace Listeners are described, along with examples that show how to configure the settings for different events. The Trace Viewer, a powerful tool that is shipped with WCF, is also described, which enables you to trace activities across service call boundaries.

Chapter 10, "Exception Handling," offers practical guidance on handling exceptions within WCF. Soap faults are described using fault contracts, and examples demonstrate how to throw and catch them to minimize errors.

Chapter 11, "Workflow Services," covers the integration points between WCF and Windows Workflow Foundation (WF) introduced in Visual Studio 2008 and .NET 3.5. We describe how to call WCF services from WF and how to expose WF workflows in WCF.

Chapter 12, "Peer Networking," shows how to build client-to-client applications that leverage a network mesh to enable clients to find each other. We cover mesh addressing and techniques for establishing point-to-point connections after the client addressing is resolved.

Chapter 13, "Programmable Web," covers how to use WCF for non-SOAP Web Services. Examples are shown with Asynchronous JavaScript and

Finally, the Appendix, "Advanced Topics," covers advanced topics that we didn't fit into other chapters. Rather than burying them somewhere they don't belong, we include them separately.

Because of the broad nature of the WCF subject, not all topics are covered in equal depth. This book's goal is to help developers be super productive when working with WCF. If we do our job, readers will use this book as they learn the technology. This book does not attempt to document WCFmdthat's what the good tech writers at Microsoft have done with the help files and MSDN. But a combination of that documentation and good guidance found in these pages should enable developers to quickly and productively build robust applications with WCF.

© Copyright Pearson Education. All rights reserved.

Read More Show Less

Table of Contents

Foreword xxv

Preface xxvii

Chapter 1: Basics 1

Chapter 2: Contracts 33

Chapter 3: Channels 91

Chapter 4: Bindings 111

Chapter 5: Behaviors 181

Chapter 6: Serialization and Encoding 241

Chapter 7: Hosting 287

Chapter 8: Security 315

Chapter 9: Diagnostics 375

Chapter 10: Exception Handling 403

Chapter 11: Workflow Services 423

Chapter 12: Peer Networking 459

Chapter 13: Programmable Web 503

Appendix: Advanced Topics 537

Index 553

Read More Show Less

Preface

Preface

Windows Communication Foundation (WCF) is the unified programming model for writing distributed applications on the Microsoft platform. It subsumes the prior technologies of ASMX, .NET Remoting, DCOM, and MSMQ and provides an extensible API to meet a wide variety of distributed computing requirements. Prior to WCF, you needed to master each of those technologies to select the right approach for a particular distributed application requirement. WCF simplifies this considerably by providing a unified approach.

XML Web Services is the most common technique for distributed computing in modern applications. They're used to expose technical and business functions on private or public networks. Sometimes they use the SOAP specification, sometimes they don't. They typically transmit information as text documents containing angle brackets, but not always. They generally use HTTP for the transport, but again, not always. WCF is a framework for working with XML Web Services and is compatible with most technology stacks.

Rich, Chris, and I have each developed code with .NET from the beginning (circa 1999). We work at Microsoft in the field, helping customers use WCF to solve real-world problems. Our customers range from large multinational corporations to ISVs to Web startups. Each has different challenges, needs, and priorities that we individually address. We show them what's possible, recommend what works well, and steer clear of what doesn't. We have experience building distributed applications and leverage that experience in teaching others about WCF.

Our goal for this book is to present WCF in a way that can immediately be put to use by software developers. We cover the material in enough detail that you know how and why to use different features. We go a bit further in most cases, describing some of the subtleties in the framework, but not so far as to document the API.

The Blogosphere is rich with WCF details. Much of it comes from the .NET product team and much of it comes from other developers learning it along the way. We made extensive use of Blogs as source material. This book brings order to that repository by organizing it in a way that can be easily consumed from your desk, sofa, or wherever you do your best reading.

Who Should Read This Book?

We wrote this book for software developers who want to build distributed applications on the .NET platform. As fellow developers, we know the importance of solid advice and clear examples on how to use new technology. We've trolled the Blogosphere, scoured internal Microsoft e-mail aliases, and wrote plenty of code to provide you with the best examples for doing the things you need to do.

Architects who need to understand WCF will also benefit from this book. The chapters covering basics, bindings, channels, behaviors, hosting, workflow, and security describe important aspects of designing and implementing services with WCF. Reading the two to three page introductions in each of these chapters may be the best way to get the 50,000-foot view of the technology.

Our goal in writing this book is to shorten your learning curve for WCF. We describe and demonstrate how to do the common tasks, addressing the basics as well as advanced topics. Throughout the book, we approach topics as a series of problems to be solved. Rather than documenting the API, we describe how to use WCF to accomplish your goals.

Prerequisites for this book are modest. If you're interested in WCF, you probably already have grounding in .NET. You're probably competent in C# or Visual Basic, or at least you were at one point. And, of course, you probably know your way around Visual Studio. So we're assuming that you're can write decent .NET code and are motivated to make the best use of your time in becoming proficient in WCF.

Installation Requirements

WCF is a key component of the Microsoft .NET Framework 3.x. WCF was first released with .NET 3.0 and has been enhanced in .NET 3.5. The delta between the two releases is modest: enhancements for non-SOAP Web services, integration between WCF and WF, and a healthy service pack. This book covers .NET 3.5. Unless there's a reason to use an older release, this is the clear recommendation.

.NET is packaged in two forms: the redistributable runtime libraries and the software development kit (SDK). The runtime libraries are meant for target machinesmdthose machines that are not for development. This includes testing, staging, and production environments. The SDK is meant for your development machines. The SDK contains code samples, documentation, and tools that are useful for development. Each of these .NET packages, the runtime and SDK versions, can be downloaded from Microsoft's MSDN site at http://msdn2.microsoft.com/en-us/netframework/default.aspx. The .NET 3.5 SDK also ships with Visual Studio 2008.

The Microsoft .NET Framework 3.5 can be installed on Windows XP SP2, Windows Vista, Windows Server 2003, and Windows Server 2008.

Organization

We don't expect you to read the book cover to cover. If you're new to WCF, you may want to read and try the samples in Chapter 1, "Basics," first. Following that, each subsequent chapter covers a major feature set of WCF. We include a few introductory pages in each chapter to describe the motivation and some design goals, and then we cover subtopics within the chapter.

Chapter 1, "Basics," is where we cover the basics of building and consuming WCF services. We discuss and demonstrate how to implement different types of interfaces and why you may choose each. By the end of this chapter, you'll be able to produce and consume services using the WCF.

Chapter 2, "Contracts," covers the three primary types of contacts in WCF: service contracts, data contracts and message contracts. Each of these enables you to define complex structures and interfaces in code. Data contracts map .NET types to XML, service contracts expose service interface endpoints in WSDL that can be consumed in a cross-platform manner, and message contracts enable developers to work directly on the XML in a message, rather than working with .NET types. For each of these contracts, WCF tools generate and export standards-based WSDL to the outside world.

Chapter 3, "Channels," covers channels and channel stacks. The channel model architecture is the foundation on which the WCF communication framework is built. The channel architecture allows for the sending and receiving of messages between clients and services. Channel stacks can be built to exactly match your needs.

Chapter 4, "Bindings," describes how to configure the communication stack to use exactly the protocols you need. For instance, if you're communicating within an enterprise and won't be crossing firewalls, and you need the fastest performance, a binding named netTcpBinding will give you best results. If you're looking to communicate with every last Web client out there, then HTTP and text encoded XML is necessary, so basicHttpBinding is the way to go. A binding is synonymous with a preconfigured channel stack.

Chapter 5, "Behaviors," covers service behaviors. In WCF, behaviors are the mechanism for affecting service operation outside of the actual message processing. Everything that is done after a message is received but before it is sent to the service operation code is the domain of behaviors. In WCF, this is where concurrency and instance management is handled, as well as transactional support. This chapter also demonstrates how to build custom behaviors for additional service control.

Chapter 6, "Serialization and Encoding," describes the process by which data is serialized from a .NET Type (class) to an XML Infoset and the way that XML Infoset is represented on the wire. We typically think of XML as a text document with angle brackets around field names and values, but the XML Infoset is a more basic data structure. This chapter discusses ways of converting that structure into a format that can be exchanged over a network.

Chapter 7, "Hosting," describes the various options in hosting a WCF service. The most common environment, IIS, is described, but it is by far not the only option. WCF services can be hosted in Managed .NET applications, Windows Activation Services, or any other .NET program. This chapter discusses the options and techniques for hosting.

Chapter 8, "Security," is a large chapter and covers the multitude of security options. Different authentication schemes are discussed and demonstrated. Transport and message level security are compared, with examples of each. Intranet and Internet scenarios are also described.

Chapter 9, "Diagnostics," describes how to use the built-in trace facilities in .NET to capture WCF events. Trace Listeners are described, along with examples that show how to configure the settings for different events. The Trace Viewer, a powerful tool that is shipped with WCF, is also described, which enables you to trace activities across service call boundaries.

Chapter 10, "Exception Handling," offers practical guidance on handling exceptions within WCF. Soap faults are described using fault contracts, and examples demonstrate how to throw and catch them to minimize errors.

Chapter 11, "Workflow Services," covers the integration points between WCF and Windows Workflow Foundation (WF) introduced in Visual Studio 2008 and .NET 3.5. We describe how to call WCF services from WF and how to expose WF workflows in WCF.

Chapter 12, "Peer Networking," shows how to build client-to-client applications that leverage a network mesh to enable clients to find each other. We cover mesh addressing and techniques for establishing point-to-point connections after the client addressing is resolved.

Chapter 13, "Programmable Web," covers how to use WCF for non-SOAP Web Services. Examples are shown with Asynchronous JavaScript and XML (AJAX) and JSON for simpler, JavaScript-friendly data formats. The hosting classes specific to non-SOAP protocols are described. Like WCF-WF integration, this is new with .NET 3.5.

Finally, the Appendix, "Advanced Topics," covers advanced topics that we didn't fit into other chapters. Rather than burying them somewhere they don't belong, we include them separately.

Because of the broad nature of the WCF subject, not all topics are covered in equal depth. This book's goal is to help developers be super productive when working with WCF. If we do our job, readers will use this book as they learn the technology. This book does not attempt to document WCFmdthat's what the good tech writers at Microsoft have done with the help files and MSDN. But a combination of that documentation and good guidance found in these pages should enable developers to quickly and productively build robust applications with WCF.

© Copyright Pearson Education. All rights reserved.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)