You are previewing Pro WCF 4: Practical Microsoft SOA Implementation, Second Edition.
O'Reilly logo
Pro WCF 4: Practical Microsoft SOA Implementation, Second Edition

Book Description

Pro WCF 4.0: Practical Microsoft SOA Implementation is a complete guide to Windows Communication Foundation from the SOA perspective, showing you why WCF is important to service-oriented architecture and development. This book provides deep insight into the functionality of WCF, which shipped with .NET 4.0-like service discovery, routing service, simplified configuration, and other advanced features. Included in this title are informative examples that will aide the reader in understanding and implementing these important additions. This book also covers the unified programming model, reliable messaging, security, and the peer-to-peer programming model. You'll also learn how to move your current .NET remoting and web service applications to WCF and how to integrate those applications with WCF 4.0. This book offers genuine insight into solving real enterprise problems using WCF and .NET 4.0.

What you'll learn

  • New features of WCF with .NET 4.0.

  • A comprehensive WCF programming model.

  • How queue management and reliable messaging work in WCF.

  • Implementing transaction support in WCF

  • Making WCF services interoperable with other SOA offerings

  • Best practicies in using WCF effectively.

  • Developing WCF applications with Visual Studio 2010.

Who this book is for

The release of .NET 4.0 brought a wide range of new functionality to WCF. Developers and architects with experience using WCF 3.5 or earlier who want to apply this new functionality to their application will benefit greatly from the discussions and code samples in this book. This book is also a great resource for application developers and architects new to SOA or the core concepts of WCF.

Table of Contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Introduction
    1. Who This Book Is For
    2. An Overview of This Book
      1. Part 1: Introducing Windows Communication Foundation
      2. Part 2: Programming with WCF
      3. Part 3: Advanced Topics in WCF
    3. Prerequisites
    4. Obtaining Updates for This Book
    5. Contacting the Author
  6. I. Introducing Windows Communication Foundation
    1. 1. WCF and SOA Basics
      1. 1.1. Understanding SOA
      2. 1.2. What Is a Service?
        1. 1.2.1. Tenet 1: Boundaries Are Explicit
        2. 1.2.2. Tenet 2: Services Are Autonomous
        3. 1.2.3. Tenet 3: Services Share the Schema and Contract, Not the Class
        4. 1.2.4. Tenet 4: Service Compatibility Is Based on Policy
      3. 1.3. A Brief History of the Microsoft Distributed Stack
      4. 1.4. Why Are Web Services the Preferred Option?
      5. 1.5. What Does WCF Solve?
      6. 1.6. Unification of Existing Technologies
      7. 1.7. Interoperability Across Platforms
      8. 1.8. WCF As a Service-Oriented Development Tool
      9. 1.9. Exploring Features in WCF
      10. 1.10. Developer Productivity
      11. 1.11. Attribute-Based Development
      12. 1.12. Coexisting with Existing Technology
      13. 1.13. Hosting Services
      14. 1.14. Migration/Integration with Existing Technology
      15. 1.15. One Service, Multiple Endpoints
      16. 1.16. Integration Technologies
      17. 1.17. How Do You Unify All These Technologies?
      18. 1.18. Summary
    2. 2. What's New in WCF 4
      1. 2.1. Introducing the ABCs of WCF
      2. 2.2. Standard Endpoints
      3. 2.3. Simplified Configuration
      4. 2.4. Default Endpoints
      5. 2.5. Default Bindings
      6. 2.6. Default Behavior
      7. 2.7. Fileless Activation
      8. 2.8. Service Discovery
      9. 2.9. Support of Visual Studio
      10. 2.10. Routing Service
      11. 2.11. Improved REST Support
      12. 2.12. Workflow Services
      13. 2.13. Summary
    3. 3. Exploring the WCF Programming Model
      1. 3.1. Introducing the Technical Architecture
      2. 3.2. Introducing the Programming Approach
      3. 3.3. WCF Programming Model
        1. 3.3.1. Addresses
          1. 3.3.1.1. Addressing HTTP
          2. 3.3.1.2. Addressing TCP
          3. 3.3.1.3. Addressing MSMQ
          4. 3.3.1.4. Addressing Named Pipes
          5. 3.3.1.5. Base Addresses
        2. 3.3.2. Bindings
        3. 3.3.3. Contracts
          1. 3.3.3.1. Message Exchange Patterns
          2. 3.3.3.2. Service Contracts and Operations
          3. 3.3.3.3. Data Contracts
          4. 3.3.3.4. Message Contracts
      4. 3.4. Looking Inside the WCF Layers
        1. 3.4.1. The Messaging Layer
          1. 3.4.1.1. Channels
          2. 3.4.1.2. Channel Shapes
          3. 3.4.1.3. Channel Flavors
      5. 3.5. Using ServiceHost and ChannelFactory
        1. 3.5.1. ServiceHost
        2. 3.5.2. ChannelFactory
        3. 3.5.3. Service Description
        4. 3.5.4. Service Runtime
      6. 3.6. Applying Behaviors
        1. 3.6.1. Service Behavior
        2. 3.6.2. Contract Behavior
        3. 3.6.3. Channel Behavior
        4. 3.6.4. Operation Behavior
        5. 3.6.5. Service Metadata Behavior
      7. 3.7. Using the Configuration Tool
      8. 3.8. Configuring Diagnostics
      9. 3.9. Configuring Instrumentation
      10. 3.10. Summary
  7. II. Programming with WCF
    1. 4. Installing and Creating WCF Services
      1. 4.1. Understanding the Requirements
        1. 4.1.1. Hardware Requirements
        2. 4.1.2. Software Requirements
      2. 4.2. Installing the .NET 4.0 Development Components
      3. 4.3. Understanding Service Contracts
        1. 4.3.1. Contract First or Code First?
        2. 4.3.2. Service Design
        3. 4.3.3. Programming Model
        4. 4.3.4. Hello World
          1. 4.3.4.1. ASP.NET 2.0 Web Service: Hello World
          2. 4.3.4.2. WCF Service: Hello World
        5. 4.3.5. Hello World with Interfaces
          1. 4.3.5.1. Service Client Proxy
        6. 4.3.6. Hosting on IIS
        7. 4.3.7. ServiceContract Attribute
        8. 4.3.8. OperationContract Attribute
        9. 4.3.9. ServiceBehavior Attribute
        10. 4.3.10. OperationBehavior Attribute
      4. 4.4. Understanding Data Contracts
        1. 4.4.1. XML Serialization
        2. 4.4.2. Data Contracts
        3. 4.4.3. Message Contracts
          1. 4.4.3.1. Summary of Service Contracts
      5. 4.5. Summary
    2. 5. Hosting and Consuming WCF Services
      1. 5.1. Hosting Environment Features
      2. 5.2. Hosting Environment Requirements
      3. 5.3. Self-Hosting Your Service
      4. 5.4. Hosting in Windows Services
      5. 5.5. Hosting Using IIS
        1. 5.5.1. Core IIS Features
        2. 5.5.2. Hosting WCF Services in IIS
        3. 5.5.3. Configuring WCF Services in IIS
        4. 5.5.4. Accessing ServiceHost in IIS
        5. 5.5.5. Recycling
        6. 5.5.6. ASP.NET Compatibility Mode
        7. 5.5.7. Windows XP and IIS 5.1
        8. 5.5.8. Windows Server 2003 and IIS 6.0
        9. 5.5.9. Hosting in IIS 7.0
        10. 5.5.10. WAS
      6. 5.6. Hosting WCF Services in Windows Azure
        1. 5.6.1. Hosting Options
      7. 5.7. Consuming WCF Services
        1. 5.7.1. Service Proxies
      8. 5.8. Summary
    3. 6. Managing WCF Services
      1. 6.1. Exploring the Business Drivers
      2. 6.2. Building Custom Code to Monitor Activity
      3. 6.3. Using Configuration Files
        1. 6.3.1. Configuration Editor: SvcConfigEditor.exe
      4. 6.4. Using Tracing and Message-Logging Capabilities
        1. 6.4.1. Message Logging
        2. 6.4.2. Enabling Message Logging
        3. 6.4.3. Enabling Tracing
        4. 6.4.4. Using SvcTraceViewer.exe
      5. 6.5. Using WCF Performance Counters
        1. 6.5.1. Enabling Built-In WCF Performance Counters
        2. 6.5.2. Creating Custom Performance Counters
      6. 6.6. Using WMI
      7. 6.7. Summary
  8. III. Advanced Topics in WCF
    1. 7. Implementing WCF Security
      1. 7.1. Business Drivers
      2. 7.2. Introducing the WCF Security Features
      3. 7.3. Security Features of Bindings
      4. 7.4. Protection Levels
      5. 7.5. Credentials and Claims
        1. 7.5.1. Presenting Credentials and Claims to WCF
        2. 7.5.2. Binding Support for Credentials
      6. 7.6. Transport-Level Security
      7. 7.7. Message-Level Security
      8. 7.8. Mixed-Mode Security
      9. 7.9. Federated Security Model in WCF
      10. 7.10. Authorization in WCF
        1. 7.10.1. Authorization Options for One-Way Communications
      11. 7.11. Auditing for Security Features in WCF
      12. 7.12. Windows CardSpace
        1. 7.12.1. How Windows CardSpace Works
        2. 7.12.2. Enabling Windows CardSpace in WCF
      13. 7.13. Summary
    2. 8. Implementing Reliable Messaging and Queue-Based Communications
      1. 8.1. The Need for Reliable Messaging
      2. 8.2. Challenges of Implementing Reliable Messaging
        1. 8.2.1. Communication Issues
        2. 8.2.2. Processing Issues
      3. 8.3. Reliable Sessions
        1. 8.3.1. Enabling WCF Web Services with Reliable Sessions
        2. 8.3.2. The ReliableSessionBindingElement Class
        3. 8.3.3. Some Pointers on Reliable Messaging
      4. 8.4. Queuing in WCF
        1. 8.4.1. Installing MSMQ
        2. 8.4.2. Microsoft Message Queues in Windows Server 2008
        3. 8.4.3. Transport Channels
        4. 8.4.4. Integration Channels
          1. 8.4.4.1. Integrating a WCF Client with an MSMQ Receiver
          2. 8.4.4.2. Integrating an MSMQ Client with a WCF Service
        5. 8.4.5. Some Pointers on Using MSMQ
      5. 8.5. Summary
    3. 9. Using Transactions in WCF
      1. 9.1. What's a Transaction?
      2. 9.2. Understanding the Types of Transactions in WCF
      3. 9.3. Defining Transactions in WCF
        1. 9.3.1. Using the TransactionFlow Attribute
        2. 9.3.2. Using the ServiceBehavior and OperationBehavior Attributes
        3. 9.3.3. Defining Transactions in QuickReturns Ltd.
      4. 9.4. Working with Transactions and Queues
      5. 9.5. Summary
    4. 10. Integrating with COM+
      1. 10.1. Why Integrate with COM+?
      2. 10.2. Running a COM+ Application As a WCF Service
        1. 10.2.1. Visual Basic 6 COM+ Component Sample Setup
        2. 10.2.2. COM+ Application WCF Service Wrapper
          1. 10.2.2.1. Using the SvcConfigEditor.exe Utility
          2. 10.2.2.2. Using the ComSvcConfig.exe Utility
          3. 10.2.2.3. Client Proxy Generation
          4. 10.2.2.4. Visual Basic 6 COM+ Hiding Interfaces
        3. 10.2.3. .NET Enterprise Services and COM+ Components
          1. 10.2.3.1. Client Proxy Generation
      3. 10.3. Consuming WCF Services from COM+
        1. 10.3.1. QuickReturns Ltd. Quote Service
          1. 10.3.1.1. Typed Contract Service Moniker
          2. 10.3.1.2. Dynamic Discovery
        2. 10.3.2. Security Credentials with IChannelCredentials
      4. 10.4. Summary
    5. 11. Working with Data
      1. 11.1. Understanding the Data Transfer Architecture
      2. 11.2. Exploring the Serialization Options in WCF
      3. 11.3. Introducing Data Contracts
        1. 11.3.1. Data Contract Names
        2. 11.3.2. Data Contract Equivalence
        3. 11.3.3. Data Contract Versioning
        4. 11.3.4. Round-Tripping
      4. 11.4. XML Serialization
        1. 11.4.1. Security
      5. 11.5. Introducing Message Contracts
        1. 11.5.1. Fine-Tuning SOAP
        2. 11.5.2. Security
        3. 11.5.3. Performance
      6. 11.6. Using the Message Class
      7. 11.7. Filtering
        1. 11.7.1. Filtering
        2. 11.7.2. Filter Tables
      8. 11.8. Best Practices for Versioning
        1. 11.8.1. Versioning with Schema Validation
        2. 11.8.2. Versioning without Schema Validation
      9. 11.9. Putting It All Together: Quote Client Sample Application
        1. 11.9.1. Creating the Service
        2. 11.9.2. Creating the Client
      10. 11.10. Summary
    6. 12. Developing Peer-to-Peer Applications with WCF
      1. 12.1. Introducing P2P Computing
        1. 12.1.1. Why Use P2P?
        2. 12.1.2. The Challenges of P2P
        3. 12.1.3. P2P Development Life Cycle
          1. 12.1.3.1. How Are Nodes Identified?
          2. 12.1.3.2. Installing the Windows P2P Networking Stack
        4. 12.1.4. Windows P2P Networking
          1. 12.1.4.1. Identity Management
          2. 12.1.4.2. Peer Names
          3. 12.1.4.3. PNRP Name Resolution
          4. 12.1.4.4. Graphing
          5. 12.1.4.5. Grouping
        5. 12.1.5. How Does a P2P Mesh Work?
          1. 12.1.5.1. Types of Mesh Networks
          2. 12.1.5.2. Types of P2P applications
        6. 12.1.6. What Is Peer Channel?
        7. 12.1.7. QuickReturnTraderChat Sample
          1. 12.1.7.1. Message Interface
          2. 12.1.7.2. Service Configuration
          3. 12.1.7.3. Binding Configuration File
          4. 12.1.7.4. Main Application
          5. 12.1.7.5. IQuickReturnTraderChat Implementation (Receiver)
          6. 12.1.7.6. Invoking the Service
        8. 12.1.8. P2P Security
          1. 12.1.8.1. Peer Channel Security
          2. 12.1.8.2. Password-Based Authentication
          3. 12.1.8.3. Certificate-Based Authentication
          4. 12.1.8.4. Message Security
        9. 12.1.9. QuickReturnSecureTraderChat Sample
          1. 12.1.9.1. Service Configuration
          2. 12.1.9.2. Binding Configuration
          3. 12.1.9.3. Main Application
      2. 12.2. Working with NetShell
        1. 12.2.1. Listing Clouds
        2. 12.2.2. Cloud Scopes
        3. 12.2.3. Listing Peers in a Cloud
        4. 12.2.4. Cloud Statistics
        5. 12.2.5. Working with Peers
      3. 12.3. SOA with P2P
      4. 12.4. Summary
    7. 13. Implementing SOA Interoperability
      1. 13.1. Achieving Java/J2EE Interoperability
        1. 13.1.1. Non-Microsoft SOA Platforms
        2. 13.1.2. Interoprability with WS-I Basic Profile
          1. 13.1.2.1. Core Components
          2. 13.1.2.2. ASP.NET Support of Basic Profile
          3. 13.1.2.3. Microsoft Web Service Extensions
          4. 13.1.2.4. WCF Basic Profile Support
        3. 13.1.3. Sending Binary Data Over Web Services
          1. 13.1.3.1. Base64 Encoding
          2. 13.1.3.2. SOAP with Attachments (SwA)
          3. 13.1.3.3. Direct Internet Message Encapsulation (DIME)
          4. 13.1.3.4. MTOM
          5. 13.1.3.5. MTOM Industry Acceptance
      2. 13.2. Using WS-ReliableMessaging
        1. 13.2.1. WS-ReliableMessaging Example
        2. 13.2.2. Platform Support of WS-ReliableMessaging
      3. 13.3. Summary
    8. A. QuickReturns Ltd.
      1. A.1. Market Overview
      2. A.2. Service and Collaboration
        1. A.2.1. Asset Manager
          1. A.2.1.1. Settle Trade (Depository)
        2. A.2.2. Market Maker
          1. A.2.2.1. Trade Security (Exchange)
          2. A.2.2.2. Settle Trade (Depository)
        3. A.2.3. Exchange
          1. A.2.3.1. Publish Quote (Market Maker)
          2. A.2.3.2. Get Quote (Asset Manager)
          3. A.2.3.3. Trade Security (Asset Manager)
        4. A.2.4. Depository
          1. A.2.4.1. Execute Trade (Exchange)
          2. A.2.4.2. Get Position (Asset Manager, Market Maker)
      3. A.3. Data Contracts
        1. A.3.1. Quote
        2. A.3.2. Trade
        3. A.3.3. Execution
        4. A.3.4. Settlement
        5. A.3.5. Position