You are previewing Windows Communication Foundation Unleashed.
O'Reilly logo
Windows Communication Foundation Unleashed

Book Description

A new edition of this title is available, ISBN-10: 0672330245 ISBN-13: 9780672330247

Windows Communication Foundation (WCF) is a new Microsoft technology for allowing 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. 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 finally delivers on the long-postponed 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 Unleashed is designed to be the best resource for software developers and architects working with WCF. The book guides readers toward a conceptual understanding of all the facilities of WCF and provides step-by-step guides to applying the technology to practical problems.

  • Introduces you to WCF and then takes you deep inside the technology

  • Gives you nearly 100 best practices for programming with WCF

  • Provides detailed coverage on how to version services that you will not find anywhere else

  • Delves into using WCF together with Windows Workflow Foundation and Windows CardSpace

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

  • Walks you through how to do secure, reliable, transacted messaging, and how to understand the options available

  • 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 your own behaviors, communication channels, message encoders, and transports

  • Gives you options for implementing publish/subscribe solutions

  • Walks you through how to do peer-to-peer communications with WCF

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

    Foreword

    Introduction

    Part I Introducing the Windows Communication Foundation

    2 The Fundamentals

    3 Data Representation

    4 Sessions, Reliable Sessions, Queues, and Transactions

    Part II Introducing the Windows Workflow Foundation

    5 Fundamentals of the Windows Workflow Foundation

    6 Using the Windows Communication Foundation and the Windows

    Part III Security

    7 Security Basics

    8 Windows CardSpace, Information Cards, and the Identity Metasystem

    9 Securing Applications with Information Cards

    10 Advanced Security

    Part IV Integration and Interoperability

    11 Legacy Integration

    12 Interoperability

    Part V Extending the Windows Communication Foundation

    13 Custom Behaviors

    14 Custom Channels

    15 Custom Transports

    Part VI Special Cases

    16 Publish/Subscribe Systems

    17 Peer Communication

    18 Representational State Transfer and Plain XML Services

    Part VII The Lifecycle of Windows Communication Foundation Applications

    19 Manageability
    20 Versioning

    Part VIII Guidance
    21 Guidance

    Index

    Table of Contents

    1. Copyright
    2. Tell Us What You Think!
    3. Foreword
    4. Introduction
    5. I. Introducing the Windows Communication Foundation
      1. 1. Prerequisites
        1. Introduction
        2. Partial Types
        3. Generics
        4. Nullable Value Types
        5. The Lightweight Transaction Manager
        6. Role Providers
        7. Summary
        8. References
      2. 2. The Fundamentals
        1. Background
        2. The Service Model
          1. A Software Resource
          2. Building a Service for Accessing the Resource
            1. Defining the Contract
            2. Hosting the Service
            3. Specifying an Address and a Binding
            4. Deploying the Service
          3. Using the Service
            1. Using the Service with a Windows Communication Foundation Client
            2. Different Ways of Coding Windows Communication Clients
            3. Using the Service with a Java Client
          4. Hosting the Service in IIS
          5. Changing How the Service Communicates
        3. Summary
        4. References
      3. 3. Data Representation
        1. Background
        2. The XmlSerializer and the DataContractSerializer
        3. The XML Fetish
          1. Building a Service
          2. Building a Client
          3. Succumbing to the Urge to Look at XML
          4. The Case for the DataContractSerializer
        4. Using the DataContractSerializer
        5. Exception Handling
        6. Summary
        7. References
      4. 4. Sessions, Reliable Sessions, Queues, and Transactions
        1. Introduction
        2. Reliable Sessions
          1. Reliable Sessions in Action
        3. Session Management
        4. Queued Delivery
          1. Enhancements in Windows Vista
            1. Dead-Letter Queues
            2. Poison Queues
        5. Transactions
        6. Summary
    6. II. Introducing the Windows Workflow Foundation
      1. 5. Fundamentals of the Windows Workflow Foundation
        1. Introduction
          1. What Is Windows Workflow Foundation?
          2. What Windows Workflow Foundation Is Not
        2. Activities
          1. Out of the Box Activities
          2. Creating Custom Activities
            1. Basic
            2. Composition
            3. Custom Composite Activities
          3. Communicating with Activities
          4. Design Behavior
            1. Validation
          5. Transactions and Compensation
        3. Workflow Models
          1. Sequential Workflows
            1. IfElse Activity
            2. Parallel Activity
          2. State Machine Workflows
          3. Custom Root Activities
        4. Workflow Hosting
          1. Hosting the Runtime
          2. Runtime Services
            1. Persistence Services
            2. Tracking Services
              1. Tracking Profiles
              2. Querying the Tracking Store
            3. Scheduler Services
            4. Other Built-in Services
              1. Loader Service
              2. Queue Services
          3. Custom Services
        5. Rules Engine
          1. Rules as Conditions
          2. The ConditionedActivityGroup Activity
          3. Rules as Policy
            1. Forward Chaining
            2. External Policy Execution
        6. Summary
        7. References
      2. 6. Using the Windows Communication Foundation and the Windows Workflow Foundation Together
        1. Introduction
        2. Consuming Services
          1. The Simple Case
          2. The General Case
        3. Orchestrating Services
        4. Exposing Workflows as Services
          1. Publishing as a Web Service
          2. Hosting Inside a WCF Service
            1. Message Routing
            2. Runtime Hosting Options
        5. Looking Ahead
        6. References
    7. III. Security
      1. 7. Security Basics
        1. Introduction
        2. Basic Tasks in Securing Communications
        3. Transport Security and Message Security
        4. Using Transport Security
          1. Installing Certificates
          2. Identifying the Certificate the Server Is to Provide
            1. Identifying a Certificate for IIS to Use for SSL Exchanges
            2. Identifying a Certificate for HTTP.SYS to Use for SSL Exchanges
          3. Configuring the Identity of the Server
          4. Transport Security in Action
        5. Using Message Security
        6. Impersonation and Authorization
        7. Impersonation
        8. Authorization
        9. Reversing the Changes to Windows
          1. Uninstalling the Certificates
          2. Removing the SSL Configuration from IIS
          3. Removing the SSL Configuration from HTTP.SYS
          4. Restoring the Identity of the Server
        10. Summary
        11. References
      2. 8. Windows CardSpace, Information Cards, and the Identity Metasystem
        1. Introduction
        2. The Role of Identity
        3. Microsoft Passport and Other Identity Solutions
        4. The Laws of Identity
        5. The Identity Metasystem
        6. Information Cards and CardSpace
        7. Managing Information Cards
        8. Architecture, Protocols, and Security
        9. CardSpace and the Enterprise
        10. Summary
        11. References
      3. 9. Securing Applications with Information Cards
        1. Introduction
        2. Developing for the Identity Metasystem
        3. Simple Demonstration of CardSpace
        4. Prerequisites for the CardSpace Samples
          1. 1. Enable Internet Information Services and ASP.NET 2.0
          2. 2. Get X.509 Certificates
          3. 3. Import the Certificates Into the Certificate Store
          4. 4. Update the Hosts File with DNS Entries to Match the Certificates
          5. 5. Internet Information Services Setup
          6. 6. Certificate Private Key Access
          7. 7. HTTP Configuration
        5. Adding Information Cards to a WCF Application
        6. Adding Information Cards
        7. Using a Federation Binding
        8. Catching Exceptions
        9. Processing the Issued Token
        10. Using the Metadata Resolver
        11. Adding Information Cards to Browser Applications
        12. Creating a Managed Card
        13. Building a Simple Security Token Service
        14. Summary
        15. References
      4. 10. Advanced Security
        1. Prelude
        2. Introduction
        3. Securing Resources with Claims
          1. Claims-Based Authorization Versus Role-Based Authorization
          2. Claims-Based Authorization Versus Access Control Lists
          3. Adopting Claims-Based Authorization
        4. Leveraging Claims-Based Security Using XSI
          1. Authorizing Access to an Intranet Resource Using Windows Identity
          2. Improving the Initial Solution
          3. Adding STSs as the Foundation for Federation
            1. Certificate Installation
            2. Adding the Fabrikam STS to the Solution
            3. The Authorization Policy of the Fabrikam STS
            4. Adding the Woodgrove STS to the Solution
          4. Reconfiguring the Resource Access Service
          5. Reconfiguring the Client
          6. Experiencing the Power of Federated, Claims-Based Identity with XSI
        5. Claims-Based Security and Federated Security
        6. Summary
        7. References
    8. IV. Integration and Interoperability
      1. 11. Legacy Integration
        1. Introduction
        2. COM+ Integration
          1. Supported Interfaces
          2. Selecting the Hosting Mode
            1. COM+ Hosted
            2. Web Hosted
            3. Web Hosted In-Process
        3. Using the COM+ Service Model Configuration Tool
        4. Exposing a COM+ Component as a Windows Communication Foundation Web Service
          1. Referencing in the Client
        5. Calling a Windows Communication Foundation Service from COM
          1. Building the Service
          2. Building the Client
          3. Building the VBScript File
          4. Testing the Solution
        6. Integrating with MSMQ
        7. Creating a Windows Communication Foundation Service That Integrates with MSMQ
          1. Creating the Request
          2. Creating the Service
          3. Creating the Client
          4. Testing
        8. Summary
      2. 12. Interoperability
        1. Summary
        2. References
    9. V. Extending the Windows Communication Foundation
      1. 13. Custom Behaviors
        1. Introduction
        2. Extending the Windows Communication Foundation
        3. Extending the Service Model with Custom Behaviors
          1. Declare What Sort of Behavior You Are Providing
          2. Attach the Custom Behavior to an Operation or Endpoint
          3. Inform the Windows Communication Foundation of the Custom Behavior
        4. Implementing a Custom Behavior
          1. Declare
          2. Attach
          3. Inform
            1. Informing the Windows Communication Foundation of a Custom Behavior in Code
            2. Informing the Windows Communication Foundation of a Custom Behavior Through Configuration
        5. Implementing Each Type of Custom Behavior
          1. Operation Selector
            1. Client
            2. Service
          2. Parameter Inspector
            1. Client
            2. Service
          3. Message Formatter
            1. Client
            2. Service
          4. Message Inspector
            1. Client
            2. Service
          5. Instance Context Provider
            1. Service
          6. Instance Provider
            1. Service
          7. Operation Invokers
            1. Service
        6. Implementing a WSDL Export Extension
          1. Implementation Steps
            1. Declare That a Type Is a WSDL Export Extension
            2. Specify Whether the WSDL Export Extension Attaches to an Endpoint or to a Contract
            3. Inform the Windows Communication Foundation of the WSDL Export Extension
        7. Custom Behaviors in Action
        8. Summary
        9. References
      2. 14. Custom Channels
        1. Introduction
        2. Binding Elements
          1. Outbound Communication
          2. Inbound Communication
        3. Channels Have Shapes
        4. Channels Might Be Required to Support Sessions
        5. Matching Contracts to Channels
        6. Communication State Machines
        7. Building Custom Binding Elements
          1. Understand the Starting Point
          2. Provide a Custom Binding Element That Supports Outbound Communication
          3. Amend the Custom Binding Element to Support Inbound Communication
          4. Applying a Custom Binding Element Through Configuration
        8. Summary
      3. 15. Custom Transports
        1. Introduction
        2. Transport Channels
          1. Inbound Communication
          2. Outbound Communication
        3. Message Encoders
        4. Completing the Stack
        5. Implementing a Transport Binding Element and an Encoder Binding Element
          1. The Scenario
          2. The Requirements
          3. The TcpListener and the TcpClient Classes
        6. Implementing Custom Binding Elements to Support an Arbitrary TCP Protocol
          1. The Configuration
          2. The Custom Transport Binding Element
          3. The Channel Listener
          4. The Transport Channel
          5. The Message Encoder
          6. Using the Custom Transport Binding Element
        7. Summary
        8. References
    10. VI. Special Cases
      1. 16. Publish/Subscribe Systems
        1. Introduction
        2. Publish/Subscribe Using Callback Contracts
        3. Publish/Subscribe Using MSMQ Pragmatic Multicasting
        4. Publish/Subscribe Using Streaming
          1. The Streamed Transfer Mode
          2. Transmitting a Custom Stream with the Streamed Transfer Mode
          3. Implementing Publish/Subscribe Using the Streamed Transfer Mode and a Custom Stream
        5. Summary
        6. References
      2. 17. Peer Communication
        1. Introducing Peer Channel
        2. Using Structured Data in Peer-to-Peer Applications
        3. Leveraging the Windows Peer-to-Peer Networking Development Platform
        4. Understanding Windows Peer-to-Peer Networks
        5. Using Peer Channel
          1. Endpoints
          2. Binding
          3. Address
          4. Contract
          5. Implementation
        6. Peer Channel in Action
          1. Envisaging the Solution
          2. Designing the Data Structures
          3. Defining the Service Contracts
          4. Implementing the Service Contracts
          5. Configuring the Endpoints
          6. Directing Messages to a Specific Peer
          7. Custom Peer Name Resolution
          8. Seeing Peer Channel Work
        7. Peer Channel and People Near Me
        8. Summary
        9. References
      3. 18. Representational State Transfer and Plain XML Services
        1. Introduction
        2. Representational State Transfer
        3. REST Services
        4. REST Services and Plain XML
        5. The Virtues and Limitations of REST Services
        6. Building REST POX Services with the Windows Communication Foundation
          1. The Address of a REST POX Service Endpoint
          2. The Binding of a REST POX Service Endpoint
          3. The Contract of a REST POX Service Endpoint
          4. Implementation
          5. A Sample Application
        7. Summary
        8. References
    11. VII. The Lifecycle of Windows Communication Foundation Applications
      1. 19. Manageability
        1. Introduction
        2. Instrumentation and Tools
          1. The Configuration System and the Configuration Editor
            1. The Configuration System
          2. The Service Configuration Editor
            1. Configuring the Trade Recording Service with the Configuration Editor
            2. Configuring a Client Application with the Configuration Editor
          3. Configurable Auditing of Security Events
          4. Message Logging, Activity Tracing, and the Service Trace Viewer
            1. Message Logging
            2. Activity Tracing
            3. The Trace Viewer
            4. Incorporating Custom Trace Sources
          5. Performance Counters
          6. WMI Provider
            1. Accessing Data from the WMI Provider via WMI CIM Studio
            2. Accessing Data from the WMI Provider Using Windows PowerShell
            3. Using the WMI Provider to Add Custom Performance Counters
        3. Completing the Management Facilities
        4. Summary
        5. References
      2. 20. Versioning
        1. Introduction
        2. Versioning Nomenclature
        3. The Universe of Versioning Problems
          1. Adding a New Operation
          2. Changing an Operation
            1. Changing the Data Contract of a Parameter
              1. Adding Optional Members to Data Contracts
              2. Other Changes to Data Contracts
            2. Other Changes to Operations
          3. Deleting an Operation
          4. Changing a Binding
          5. Deciding to Retire an Endpoint
          6. Changing the Address of a Service Endpoint
        4. Centralized Lifecycle Management
        5. Summary
        6. References
    12. VIII. Guidance
      1. 21. Guidance
        1. Introduction
        2. Adopting the Windows Communication Foundation
        3. Working with Windows Communication Foundation Addresses
        4. Working with Windows Communication Foundation Bindings
        5. Working with Windows Communication Foundation Contracts
          1. Working with Structural Contracts
          2. Working with Behavioral Contracts
        6. Working with Windows Communication Foundation Services
          1. Ensuring Manageability
        7. Working with Windows Communication Foundation Clients
        8. Working with Large Amounts of Data
        9. Debugging Windows Communication Foundation Applications
        10. Summary
        11. References