Home > Store > Operating Systems, Server > Microsoft Servers

Windows Communication Foundation 3.5 Unleashed, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

Windows Communication Foundation 3.5 Unleashed, 2nd Edition

eBook (Watermarked)

  • Your Price: $35.19
  • List Price: $43.99
  • Includes EPUB, MOBI, and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Description

  • Copyright 2009
  • Pages: 768
  • Edition: 2nd
  • eBook (Watermarked)
  • ISBN-10: 0-13-265015-0
  • ISBN-13: 978-0-13-265015-1

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

Sample Content

Table of Contents

Part I Introducing the Windows Communication Foundation

Chapter 1 Prerequisites 9

Partial Types ....................................................................................................9

Generics.........................................................................................................10

Nullable Value Types.....................................................................................13

The Lightweight Transaction Manager.........................................................14

Role Providers ...............................................................................................16

Summary .......................................................................................................18

References......................................................................................................19

Chapter 2 The Fundamentals 21

Background ...................................................................................................21

Enter Services ................................................................................................24

Windows Communication Foundation .......................................................26

The Service Model.........................................................................................28

    A Software Resource.............................................................................34

    Building a Service for Accessing the Resource ....................................36

    Using the Service .................................................................................55

    Hosting the Service in IIS ....................................................................67

    Changing How the Service Communicates ........................................72

Visual Studio 2008 Tool Support ..................................................................75

Summary .......................................................................................................82

References......................................................................................................83

Chapter 3 Data Representation and Durable Services 85

Background ...................................................................................................85

The XmlSerializer and the DataContractSerializer.......................................87

The XML Fetish.............................................................................................91

    Building a Service ................................................................................92

    Building a Client..................................................................................95

    Succumbing to the Urge to Look at XML...........................................95

    The Case for the DataContractSerializer .............................................95

Using the DataContractSerializer .................................................................96

Exception Handling ....................................................................................110

Durable Services ..........................................................................................114

    Why Durable Services? ......................................................................114

    Implementing Durable Services ........................................................115

Summary .....................................................................................................122

References....................................................................................................123

Chapter 4 Sessions, Reliable Sessions, Queues, and Transactions 125

Reliable Sessions..........................................................................................125

Reliable Sessions in Action ................................................................127

Session Management ..................................................................................129

Queued Delivery .........................................................................................130

Enhancements in Windows Vista .....................................................132

Transactions ................................................................................................134

Summary .....................................................................................................143

Part II Introducing the Windows Workflow Foundation

chapter 5 Fundamentals of the Windows Workflow Foundation 147

What Is Windows Workflow Foundation?.................................................147

    What Windows Workflow Foundation Is Not ..................................148

Activities......................................................................................................149

    Out of the Box Activities ...................................................................151

    Creating Custom Activities ...............................................................152

    Communicating with Activities ........................................................160

    Design Behavior.................................................................................167

    Transactions and Compensation.......................................................170

Workflow Models ........................................................................................172

    Sequential Workflows ........................................................................175

    State Machine Workflows..................................................................183

    Custom Root Activities......................................................................184

Workflow Hosting.......................................................................................184

    Hosting the Runtime .........................................................................185

    Runtime Services................................................................................186

    Custom Services.................................................................................196

Rules Engine................................................................................................199

    Rules as Conditions ...........................................................................200

    The ConditionedActivityGroup Activity...........................................202

    Rules as Policy....................................................................................204

Summary .....................................................................................................207

References....................................................................................................207

Chapter 6 Using the Windows Communication Foundation

and the Windows Workflow Foundation Together 209

Consuming Services....................................................................................210

    Calling Services in a Custom Activity...............................................210

    Using the Send Activity (the 3.5 Approach) .....................................214

    Extending the Send Activity..............................................................217

Orchestrating Services.................................................................................219

Exposing Workflows as Services .................................................................220

    Hosting Inside a WCF Service (.NET 3.0)..........................................220

    Exposing a Workflow as a Service (.NET 3.5)....................................226

    Creating a Workflow Service .............................................................233

    Context ..............................................................................................234

    Patterns of Communication..............................................................237

Summary .....................................................................................................248

References....................................................................................................248

Part III Security

Chapter 7 Security Basics 251

Basic Tasks in Securing Communications ..................................................251

Transport Security and Message Security ...................................................252

Using Transport Security.............................................................................253

    Installing Certificates.........................................................................253

    Identifying the Certificate the Server Is to Provide ..........................255

    Configuring the Identity of the Server .............................................256

    Transport Security in Action .............................................................257

Using Message Security...............................................................................263

Impersonation and Authorization..............................................................269

Impersonation.............................................................................................269

Authorization ..............................................................................................272

Reversing the Changes to Windows...........................................................281

    Uninstalling the Certificates .............................................................281

    Removing the SSL Configuration from IIS .......................................282

    Removing the SSL Configuration from HTTP.SYS ............................283

    Restoring the Identity of the Server..................................................283

Summary .....................................................................................................283

References....................................................................................................284

Chapter 8 Windows CardSpace, Information Cards, and the Identity Metasystem 285

The Role of Identity ....................................................................................285

Microsoft Passport and Other Identity Solutions ......................................288

The Laws of Identity ...................................................................................290

The Identity Metasystem ............................................................................291

Information Cards and CardSpace .............................................................297

Managing Information Cards .....................................................................299

Architecture, Protocols, and Security .........................................................306

CardSpace and the Enterprise.....................................................................319

New Features in .NET Framework 3.5 ........................................................322

HTTP Support in .NET Framework 3.5 .......................................................324

Summary .....................................................................................................326

References....................................................................................................327

Chapter 9 Securing Applications with Information Cards 329

Developing for the Identity Metasystem....................................................329

Simple Demonstration of CardSpace..........................................................331

Prerequisites for the CardSpace Samples ....................................................332

    1) Enable Internet Information Services and ASP.NET 2.0 ...............333

    2) Get X.509 Certificates ...................................................................333

    3) Import the Certificates into the Certificate Store.........................334

    4) Update the Hosts File with DNS Entries to Match the Certificates .........334

    5) Internet Information Services Setup .............................................335

    6) Certificate Private Key Access .......................................................335

    7) HTTP Configuration......................................................................336

Adding Information Cards to a WCF Application.....................................337

Adding Information Cards .........................................................................342

Using a Federation Binding ........................................................................347

Catching Exceptions ...................................................................................348

Processing the Issued Token .......................................................................350

Using the Metadata Resolver ......................................................................351

Adding Information Cards to Browser Applications..................................353

Creating a Managed Card...........................................................................364

Building a Simple Security Token Service ..................................................367

Using CardSpace over HTTP .......................................................................370

Summary .....................................................................................................370

References....................................................................................................370

Chapter 10 Advanced Security 371

Prelude.........................................................................................................371

Securing Resources with Claims .................................................................372

    Claims-Based Authorization Versus Role-Based Authorization ........373

    Claims-Based Authorization Versus Access Control Lists .................374

Leveraging Claims-Based Security Using XSI .............................................377

    Authorizing Access to an Intranet Resource Using

    Windows Identity............................................................................377

    Improving the Initial Solution ..........................................................384

    Adding STSs as the Foundation for Federation.................................391

    Reconfiguring the Resource Access Service .......................................405

    Reconfiguring the Client ...................................................................408

    Experiencing the Power of Federated,

Claims-Based Identity with XSI ......................................................411

Claims-Based Security and Federated Security ...........................................412

Summary .....................................................................................................413

References....................................................................................................414

Part IV Integration and Interoperability

Chapter 11 Legacy Integration 417

COM+ Integration.......................................................................................417

    Supported Interfaces ..........................................................................418

    Selecting the Hosting Mode ..............................................................419

Using the COM+ Service Model Configuration Tool.................................419

Exposing a COM+ Component as a Windows

Communication Foundation Web Service...............................................421

    Referencing in the Client ..................................................................426

Calling a Windows Communication Foundation Service from COM ......428

    Building the Service...........................................................................428

    Building the Client ............................................................................431

    Building the VBScript File .................................................................433

    Testing the Solution...........................................................................433

Integrating with MSMQ..............................................................................433

Creating a Windows Communication Foundation Service

That Integrates with MSMQ.....................................................................434

    Creating the Request .........................................................................434

    Creating the Service...........................................................................435

    Creating the Client............................................................................438

Testing................................................................................................442

Summary .....................................................................................................443

Chapter 12 Interoperability 445

Summary .....................................................................................................448

References....................................................................................................448

Part V Extending the Windows Communication Foundation

Chapter 13 Custom Behaviors 451

Extending the Windows Communication Foundation .............................451

Extending the Service Model with Custom Behaviors ..............................452

    Declare What Sort of Behavior You Are Providing ...........................453

    Attach the Custom Behavior to an Operation or Endpoint.............457

    Inform the Windows Communication Foundation of the Custom Behavior ....457

Implementing a Custom Behavior .............................................................458

    Declare the Behavior .........................................................................458

    Attach.................................................................................................458

    Inform................................................................................................459

Implementing Each Type of Custom Behavior..........................................467

    Operation Selector .............................................................................467

    Parameter Inspector...........................................................................469

    Message Formatter .............................................................................471

    Message Inspector..............................................................................473

    Instance Context Provider.................................................................476

    Instance Provider ...............................................................................477

    Operation Invokers............................................................................478

Implementing a WSDL Export Extension ..................................................479

    Implementation Steps .......................................................................480

Custom Behaviors in Action.......................................................................482

Summary .....................................................................................................483

References....................................................................................................483

Chapter 14 Custom Channels 485

Binding Elements........................................................................................485

    Outbound Communication ..............................................................486

    Inbound Communication .................................................................487

Channels Have Shapes................................................................................488

Channels Might Be Required to Support Sessions .....................................490

Matching Contracts to Channels ...............................................................490

Communication State Machines ................................................................492

Building Custom Binding Elements ...........................................................493

    Understand the Starting Point ..........................................................493

    Provide a Custom Binding Element That Supports Outbound Communication ............495

    Amend the Custom Binding Element to Support Inbound Communication.....................502

    Applying a Custom Binding Element Through Configuration ........................................508

Summary .....................................................................................................511

Chapter 15 Custom Transports 513

Transport Channels.....................................................................................513

    Inbound Communication .................................................................514

    Outbound Communication ..............................................................514

Message Encoders........................................................................................514

Completing the Stack .................................................................................514

Implementing a Transport Binding Element and an

Encoder Binding Element.........................................................................516

    The Scenario ......................................................................................516

    The Requirements..............................................................................517

    The TcpListener and the TcpClient Classes.......................................517

Implementing Custom Binding Elements to Support an Arbitrary TCP Protocol ...........520

    The Configuration .............................................................................520

    The Custom Transport Binding Element ..........................................522

    The Channel Listener ........................................................................525

    The Transport Channel .....................................................................528

    The Message Encoder.........................................................................530

    Using the Custom Transport Binding Element.................................532

Summary .....................................................................................................532

References....................................................................................................533

Part VI Special Cases

Chapter 16 Publish/Subscribe Systems 537

Publish/Subscribe Using Callback Contracts..............................................538

Publish/Subscribe Using MSMQ Pragmatic Multicasting ..........................544

Publish/Subscribe Using Streaming ............................................................552

    The Streamed Transfer Mode.............................................................553

    Transmitting a Custom Stream with the Streamed Transfer Mode.......557

    Implementing Publish/Subscribe Using the Streamed Transfer Mode and a Custom Stream .......561

Summary .....................................................................................................565

References....................................................................................................566

Chapter 17 Peer Communication 567

Using Structured Data in Peer-to-Peer Applications ..................................567

Leveraging the Windows Peer-to-Peer Networking

Development Platform .............................................................................568

Understanding Windows Peer-to-Peer Networks .......................................569

Using Peer Channel ....................................................................................569

    Endpoints...........................................................................................569

    Binding ..............................................................................................570

    Address...............................................................................................574

    Contract .............................................................................................574

    Implementation.................................................................................575

Peer Channel in Action ..............................................................................575

    Envisaging the Solution ....................................................................575

    Designing the Data Structures...........................................................579

    Defining the Service Contracts .........................................................581

    Implementing the Service Contracts ................................................584

    Configuring the Endpoints ...............................................................585

    Directing Messages to a Specific Peer................................................587

    Custom Peer Name Resolution..........................................................590

    Seeing Peer Channel Work ................................................................595

Peer Channel and People Near Me.............................................................598

Summary .....................................................................................................598

References....................................................................................................598

Chapter 18 Representational State Transfer and Plain XML Services 599

Representational State Transfer ..................................................................599

REST Services...............................................................................................600

REST Services and Plain XML .....................................................................600

The Virtues and Limitations of REST Services............................................601

Building REST POX Services with the Windows Communication Foundation ........602

    The Address of a REST POX Service Endpoint..................................602

    The Binding of a REST POX Service Endpoint..................................602

    The Contract of a REST POX Service Endpoint ................................603

    Implementation.................................................................................604

    A Sample Application ........................................................................604

RSS and ATOM Syndication in .NET Framework 3.5.................................609

JSON ............................................................................................................615

    A Sample ASP.NET AJAX+JSON Application .....................................616

Summary .....................................................................................................620

References....................................................................................................620

Part VII The Lifecycle of Windows Communication Foundation Applications

Chapter 19 Manageability 623

Instrumentation and Tools .........................................................................624

    The Configuration System and the Configuration Editor................625

    The Service Configuration Editor......................................................627

    Configurable Auditing of Security Events.........................................633

    Message Logging, Activity Tracing, and the Service Trace Viewer .......636

    Performance Counters .......................................................................647

    WMI Provider ....................................................................................649

Completing the Management Facilities .....................................................658

Summary .....................................................................................................659

Chapter 20 Versioning 661

Versioning Nomenclature...........................................................................662

The Universe of Versioning Problems ........................................................662

    Adding a New Operation...................................................................662

    Changing an Operation.....................................................................664

    Deleting an Operation.......................................................................668

    Changing a Binding ..........................................................................669

    Deciding to Retire an Endpoint ........................................................669

    Changing the Address of a Service Endpoint ...................................670

Centralized Lifecycle Management ............................................................670

Summary .....................................................................................................673

References....................................................................................................673

Part VIII Guidance

Chapter 21 Guidance 677

Adopting the Windows Communication Foundation...............................677

Working with Windows Communication Foundation Addresses.............679

Working with Windows Communication Foundation Bindings ..............681

Working with Windows Communication Foundation Contracts.............684

    Working with Structural Contracts ...................................................687

    Working with Behavioral Contracts..................................................689

Working with Windows Communication Foundation Services ................691

    Ensuring Manageability.....................................................................695

Working with Windows Communication Foundation Clients .................699

Working with Large Amounts of Data .......................................................705

Debugging Windows Communication Foundation Applications .............707

Summary .....................................................................................................708

References....................................................................................................709

Updates

Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership