Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Learning WCF
A Note Regarding Supplemental Files
Forewords
Preface
Who This Book Is For
How This Book Is Organized
Chapters Overview
Labs and Code Samples
Assumptions About the Reader
System Requirements
Your Working Directory
Conventions Used in This Book
Comments and Questions
SafariĀ® Enabled
Acknowledgments
1. Hello Indigo
1.1. Service Oriented Architecture
1.1.1. From OOP to SOA
1.1.2. What Is a Service?
1.1.3. Tenets of SOA
1.1.3.1. Service boundaries are explicit
1.1.3.2. Services are autonomous
1.1.3.3. Clients and services share contracts, not code
1.1.3.4. Compatibility is based upon policy
1.1.4. Big SOA, Little SOA
1.2. WCF Services
1.3. Fundamental WCF Concepts
1.3.1. Message Serialization
1.3.2. Services
1.3.3. Hosting
1.3.4. Endpoints
1.3.5. Addresses
1.3.6. Bindings
1.3.7. Metadata
1.3.8. Proxies
1.3.9. Channels
1.3.10. Behaviors
1.4. Creating a New Service from Scratch
1.4.1. Lab: Creating Clients and Services Programmatically
1.4.1.1. Creating a new service
1.4.1.2. Hosting a service
1.4.1.3. Creating a proxy to invoke a service
1.4.2. Assembly Allocation
1.4.3. Defining a Service
1.4.4. Hosting a Service
1.4.5. Exposing Service Endpoints
1.4.5.1. Addresses
1.4.5.2. Bindings
1.4.5.3. Contracts
1.4.6. Creating a Client Proxy
1.5. Generating a Service and Client Proxy
1.5.1. Lab: Using Tools to Generate Clients and Services
1.5.1.1. Using the WCF Service template
1.5.1.2. Configuring service endpoints using the Service Configuration Editor
1.5.1.3. Generating a proxy with Add Service Reference
1.5.1.4. Creating a WCF Service Library
1.5.1.5. Generating a proxy using the Service Model Metadata Utility
1.5.2. Service Templates
Service Testing Tools
1.5.3. ServiceModel Metadata Utility
1.5.4. Service Configuration Editor
1.5.5. ServiceModel Configuration
1.5.6. ServiceHost Initialization
1.5.7. Enabling Metadata Exchange
1.5.8. Working with Behaviors
1.5.8.1. Service behaviors
1.5.8.2. Endpoint behaviors
1.5.9. Proxy Initialization
1.6. Hosting a Service in IIS
1.6.1. Lab: Creating an IIS Host and Browsing Metadata
1.6.1.1. Creating a WCF Service web site
1.6.1.2. Browsing service metadata
1.6.1.3. Exporting metadata for proxy generation
1.6.2. Web Site Templates
1.6.3. @ServiceHost Declarations
1.6.4. Message-Based Activation
1.6.5. Browsing and Exporting Metadata
1.6.5.1. Browsing metadata
1.6.5.2. Exporting metadata
1.7. Exposing Multiple Service Endpoints
1.7.1. Lab: Hosting Multiple Services and Sharing Types
1.7.1.1. Implementing multiple contracts on a service
1.7.1.2. Hosting two services with multiple contracts
1.7.1.3. Consuming internal services using shared contracts
1.7.1.4. Consuming external services with a generated proxy
1.7.2. Implementing Multiple Contracts
1.7.3. Hosting Multiple Services
1.7.4. Proxy Generation for Multiple Contracts and Endpoints
1.7.5. Proxy Initialization and Lifetime
1.7.6. Sharing Service Contracts
1.7.7. Duplicating Operations
1.8. Summary
2. Contracts
2.1. Messaging Protocols
2.1.1. SOAP
2.1.2. WS*
2.2. Service Description
2.2.1. ServiceDescription
2.2.2. WSDL
2.2.3. WS-Policy
2.2.4. WS-MetadataExchange
2.3. WCF Contracts and Serialization
2.4. Service Contracts
2.4.1. Lab: Designing a Service Contract
2.4.1.1. Exploring service contract compatibility
2.4.1.2. Customizing message parameters
2.4.1.3. Modifying service operations and dealing with version tolerance
2.4.2. Mapping Services to WSDL
2.4.3. Designing Service Contracts
2.4.3.1. ServiceContractAttribute
2.4.3.2. OperationContractAttribute
2.4.3.3. MessageParameterAttribute
2.4.4. Versioning Service Contracts
2.4.4.1. Versioning with contract inheritance
2.4.4.2. Versioning with separate contracts
2.4.4.3. Strict versus non-strict versioning
2.5. Data Contracts
2.5.1. Lab: Working with Data Contracts
2.5.1.1. Creating a data contract
2.5.1.2. Customizing data contract serialization
2.5.1.3. Consuming data contracts at the client
2.5.1.4. Exploring version tolerance
2.5.2. Mapping Data Contracts to XSD Schema
2.5.3. Designing Data Contracts
2.5.3.1. DataContractAttribute
2.5.3.2. DataMemberAttribute
2.5.3.3. EnumMemberAttribute
2.5.3.4. CollectionDataContractAttribute
2.5.4. Mapping CLR Namespace to Schema Namespace
2.5.5. Configuring Known Types
2.5.5.1. KnownTypeAttribute
2.5.5.2. ServiceKnownTypeAttribute
2.5.5.3. Declarative known types
2.5.6. Versioning Data Contracts
2.5.6.1. IExtensibleDataObject
2.5.6.2. Explicit versioning
2.5.6.3. Versioning flow diagrams
2.5.7. Data Contracts As Operation Messages
2.6. Message Contracts
2.6.1. Lab: Controlling Message Serialization with Message Contracts
2.6.1.1. Creating message contracts
2.6.1.2. Implementing message contracts in a service
2.6.1.3. Using proxies and message contracts
2.6.2. Message Contracts and SOAP
2.6.3. Designing Message Contracts
2.6.3.1. MessageContractAttribute
2.6.3.2. MessageBodyMemberAttribute
2.6.3.3. MessageHeaderAttribute
2.6.4. Client Message Contracts
2.6.5. Versioning Message Contracts
2.7. Approaches to Serialization
2.7.1. Types Supporting Serialization
2.7.2. Serialization Format
2.7.2.1. Message Encoding
2.7.2.2. DataContractFormatAttribute
2.7.2.3. XmlSerializerFormatAttribute
2.7.3. Applying the XmlSerializer
2.7.3.1. Controlling serialization
2.7.3.2. Proxy generation and the XmlSerializer
2.7.4. Applying IXmlSerializable Types
2.7.4.1. Implementing IXmlSerializable
2.7.4.2. Supplying a schema
2.8. The Message Type
2.8.1. Lab: Working with Raw Messages
2.8.1.1. Using untyped messages in the service contract
2.8.1.2. Accessing message headers
2.8.1.3. Extending the message type
2.8.2. Untyped Messages and WSDL
2.8.3. Working with the Message Type
2.8.3.1. Creating messages
2.8.3.2. Accessing message headers
2.8.4. Filtering Messages
2.9. Summary
3. Bindings
3.1. How Bindings Work
3.1.1. Standard Bindings
3.1.2. Binding Features
3.1.3. Binding Elements
3.1.4. Building the Channel Stack
3.1.5. Web Service Protocols
3.1.6. Bindings and Metadata
3.1.7. Constraints on Binding Selection
3.2. Web Service Bindings
3.2.1. Lab: Exposing Web Services with BasicHttpBinding and WSHttpBinding
3.2.1.1. Exposing multiple web service endpoints
3.2.1.2. Adding a web reference for the legacy client
3.2.1.3. Adding a service reference for the non-legacy client
3.2.2. Choosing a Web Service Binding
3.2.3. BasicHttpBinding Features
3.2.3.1. BasicHttpBinding defaults
3.2.3.2. Customizing BasicHttpBinding
3.2.4. WSHttpBinding Features
3.2.4.1. WSHttpBinding defaults
3.2.4.2. Customizing WSHttpBinding
3.2.5. MessageVersion
3.2.6. Isolating SOAP 1.1 and SOAP 1.2 Endpoints
3.3. Connection-Oriented Bindings
3.3.1. Lab: Distributing Calls with NetNamedPipeBinding and NetTcpBinding
3.3.1.1. Setting up the lab
3.3.1.2. Moving from components to services
3.3.1.3. Crossing machine boundaries
3.3.2. Choosing a Connection-Oriented Binding
3.3.3. NetNamedPipeBinding Features
3.3.3.1. NetNamedPipeBinding defaults
3.3.3.2. Customizing NetNamedPipeBinding
3.3.4. NetTcpBinding Features
3.3.4.1. NetTcpBinding defaults
3.3.4.2. Customizing NetTcpBinding
3.3.5. Calling Services In-Process
3.3.6. Distribution of Services
3.4. One-Way and Duplex Communication
3.4.1. Message Exchange Patterns
3.4.1.1. Request-reply
3.4.1.2. One-way
3.4.1.3. Duplex
3.4.2. Working with Callbacks
3.4.2.1. Duplex proxies
3.4.2.2. DuplexChannelFactory<T>
3.4.2.3. Callback instance
3.4.2.4. Client endpoint
3.4.3. Lab: Duplex Communications over TCP and HTTP
3.4.3.1. Designing the callback contract
3.4.3.2. Issuing callbacks
3.4.3.3. Choosing a duplex-compatible binding
3.4.3.4. Implementing the callback contract
3.4.3.5. Issuing callbacks over WSDualHttpBinding
3.4.3.6. Callbacks and one-way operations
3.4.4. WSDualHttpBinding Features
3.4.4.1. WSDualHttpBinding defaults
3.4.4.2. Customizing WSDualHttpBinding
3.4.5. Services and Callback References
3.4.6. Callbacks and Concurrency
3.5. Large Message Transfers
3.5.1. Lab: Using MTOM to Handle Large Messages with Binary Data
3.5.2. Lab: Enabling Streaming for Large File Transfers
3.5.2.1. Streaming from the service
3.5.2.2. Streaming from the client
3.5.3. Handling Large Messages
3.5.3.1. Controlling payload size
3.5.3.2. Reducing memory consumption
3.5.4. Message Size Quotas
3.5.5. MTOM Encoding
3.5.6. Streaming
3.5.6.1. Designing a service contract for streaming
3.5.6.2. Enabling streaming
3.5.6.3. Who closes the stream?
3.5.6.4. Alternatives to streaming
3.6. Custom Bindings
3.6.1. CustomBinding Features
3.6.2. Creating a CustomBinding
3.6.2.1. Binary encoding over HTTP
3.6.2.2. SOAP 1.2 without addressing headers
3.7. Summary
4. Hosting
4.1. Hosting Features
4.2. ServiceHost
4.2.1. Initializing the ServiceHost
4.2.2. Declarative Configuration
4.2.3. Base Addresses
4.2.4. ServiceHost and ServiceDescription
4.2.5. Closing the ServiceHost
4.2.6. Communication Events
4.3. Self-Hosting
4.3.1. Console Applications
4.3.2. Windows Applications
4.3.3. Windows Services
4.4. Hosting on the UI Thread
4.4.1. Windows Applications and UI Threads
4.4.2. Synchronization Context
4.4.3. ServiceHost Lifetime
4.4.4. Lab: Working with a Windows Forms Host
4.4.4.1. Configuring the ServiceHost
4.4.4.2. Opening and closing the ServiceHost
4.4.4.3. Calling services on a non-UI thread
4.4.4.4. Calling services on the UI thread
4.4.4.5. Preventing services from joining the UI thread
4.4.5. Callbacks and the UI Thread
4.4.6. UI Hosting Scenarios
4.4.6.1. Coupling services to the host user interface
4.4.6.2. Exposing a reusable service user interface
4.4.6.3. Decoupling services from user interfaces
4.5. Hosting in a Windows Service
4.5.1. What Are Windows Services?
4.5.1.1. Controlling service startup
4.5.1.2. Runtime identities
4.5.1.3. Recovery
4.5.2. Creating and Installing Windows Services
4.5.2.1. Extending ServiceBase
4.5.2.2. Event log access
4.5.2.3. Registering the Windows service
4.5.2.4. Providing an installer
4.5.3. Lab: Creating a Windows Service Host
4.5.3.1. Creating a new Windows Service
4.5.3.2. Handling start and stop events
4.5.3.3. Creating a Windows service installer
4.5.3.4. Generating the client proxy
4.5.4. Considerations for WCF Services
4.5.5. Windows Service Hosting Scenarios
4.6. Hosting in IIS 6.0
4.6.1. IIS Service Endpoints
4.6.2. IIS 6.0 Hosting Architecture
4.6.3. ASP.NET Compatibility Mode
4.7. IIS 7.0 and Windows Activation Service
4.7.1. WAS Hosting Architecture
4.7.2. Installing IIS 7.0, WAS, and WCF Communications
4.7.3. Configuring IIS 7.0 and WAS
4.7.4. Hosting WCF Services with WAS
4.8. Choosing the Right Hosting Environment
4.9. Summary
5. Instancing and Concurrency
5.1. OperationContext
5.2. Instancing
5.2.1. PerCall Services
5.2.2. PerSession Services
5.2.2.1. Requiring sessions
5.2.2.2. Session identifier
5.2.2.3. Session lifetime
5.2.2.4. Exception handling
5.2.3. Singleton Services
5.2.4. Lab: Controlling Service Instancing
5.2.4.1. Working with PerCall services
5.2.4.2. Working with sessions
5.2.4.3. Working with singletons
5.3. Concurrency
5.3.1. Single Concurrency Mode
5.3.2. Reentrant Concurrency Mode
5.3.3. Multiple Concurrency Mode
5.3.4. Custom Synchronization
5.3.5. .NET Synchronization Techniques
5.3.6. Asynchronous Proxies
5.3.7. Lab: Protecting Shared Resources from Concurrent Access
5.3.7.1. Generating an asynchronous proxy
5.3.7.2. Allowing concurrent access to the singleton
5.3.7.3. Adding manual synchronization with global locks
5.3.7.4. Adding more granular synchronization for increased throughput
5.4. Instance Throttling
5.4.1. Throttling PerCall Services
5.4.2. Throttling Sessions
5.4.3. Throttling Singletons
5.5. Load Balancing and Failover
5.6. Summary
6. Reliability
6.1. Reliable Sessions
6.1.1. Configuring Reliable Sessions
6.1.1.1. Standard bindings
6.1.1.2. Custom bindings
6.1.1.3. Requiring ordered delivery
6.1.1.4. Client configuration
6.1.2. How Reliable Sessions Work
6.1.2.1. Session identifier
6.1.2.2. Session lifetime
6.1.2.3. Retry attempts
6.1.2.4. Session throttling
6.1.3. WS-ReliableMessaging Protocol
6.1.3.1. Message flow
6.1.3.2. CreateSequence
6.1.3.3. CreateSequenceResponse
6.1.3.4. SequenceAcknowledgement
6.1.3.5. LastMessage
6.1.3.6. TerminateSequence
6.1.4. Lab: Working with Reliable Sessions
6.1.4.1. Tracing reliable sessions messages
6.1.4.2. Testing reliable session retries
6.2. Transactions
6.2.1. Transaction Management
6.2.1.1. Two-phase commit protocol
6.2.1.2. Durable versus volatile resource managers
6.2.1.3. TransactionScope
6.2.1.4. Lightweight Transaction Manager
6.2.1.5. Kernel Transaction Manager
6.2.1.6. Distributed Transaction Coordinator
6.2.1.7. WS-AtomicTransaction and WS-Coordination protocols
6.2.1.8. Enabling WS-AT
6.2.2. Transactions and System Tiers
6.2.3. Configuring WCF Transactions
6.2.3.1. Enabling transaction flow
6.2.3.2. Selecting a transaction protocol
6.2.3.3. Transaction flow options
6.2.3.4. Service operations and transactions
6.2.3.5. Controlling IsolationLevel
6.2.3.6. Transaction timeout
6.2.3.7. Client configuration
6.2.3.8. Transactions and sessions
6.2.4. Lab: Configuring WCF Transactions
6.2.4.1. Testing service calls without transactions
6.2.4.2. Requiring client transactions
6.2.4.3. Automating service transactions
6.2.4.4. Rejecting client transactions
6.3. Queued Calls
6.3.1. MSMQ Overview
6.3.1.1. Private and public queues
6.3.1.2. Transactional queues
6.3.1.3. Delivery failure
6.3.1.4. Security
6.3.1.5. MSMQ management console
6.3.1.6. System.Messaging
6.3.2. NetMsmqBinding Features
6.3.3. Queued Service Contracts
6.3.4. Durable Queues
6.3.5. Transactional Queues
6.3.5.1. Exactly once delivery
6.3.5.2. Client transactions
6.3.5.3. Queue-to-queue transactions
6.3.5.4. Queued service transactions
6.3.6. Transactions and Delivery Failures
6.3.6.1. Delivery retries
6.3.6.2. Time-to-live
6.3.6.3. Poison messages
6.3.6.4. Poison message queue
6.3.6.5. Dead letter queues
6.3.7. Security
6.3.8. MsmqIntegrationBinding
6.3.9. Lab: Creating a Queued Service
6.3.9.1. Exposing an MSMQ endpoint
6.3.9.2. Requiring MSMQ
6.3.9.3. Testing offline messaging
6.3.9.4. Testing exception handling
6.4. Summary
7. Security
7.1. WCF Security Overview
7.1.1. Security Policy
7.1.2. Binding Security
7.1.2.1. Default security settings
7.1.2.2. Security mode
7.1.2.3. Client credential type
7.1.2.4. Advanced dettings
7.1.3. Supplying Credentials
7.1.3.1. Client credentials
7.1.3.2. Service credentials
7.1.4. Message Protection
7.1.4.1. Protection level
7.1.4.2. Algorithm suite
7.1.5. Authentication, Authorization, and Identities
7.1.5.1. ServiceSecurityContext
7.1.5.2. Security tokens and authentication
7.1.5.3. Role-based authorization
7.1.5.4. Impersonation
7.1.6. WCF Security Summary
7.2. Securing Intranet Services
7.2.1. Lab: Authenticating and Authorizing Windows Credentials
7.2.1.1. Authenticating with Windows credentials
7.2.1.2. Initializing the proxy with Windows credentials
7.2.1.3. Applying Windows role-based permission demands
7.2.2. NetNamedPipeBinding Security Features
7.2.3. NetTcpBinding Security Features
7.2.4. Windows Authentication and Authorization
7.2.5. Windows Role-Based Security
7.2.6. Windows Client Credentials
7.3. Securing Internet Services
7.3.1. Lab: Authenticating and Authorizing UserName Credentials
7.3.1.1. Creating two service endpoints
7.3.1.2. Generating the client proxy
7.3.1.3. Configuring binding security
7.3.1.4. Initializing proxies with UserName credentials
7.3.1.5. Configuring ASP.NET authentication and authorization
7.3.1.6. Applying custom role-based permission demands
7.3.2. BasicHttpBinding Security Features
7.3.3. WSHttpBinding Security Features
7.3.4. Negotiation
7.3.5. Secure Sessions
7.3.6. ASP.NET Authentication and Authorization
7.3.6.1. Configuring ASP.NET providers
7.3.6.2. Custom password validators
7.3.7. Custom Role-Based Security
7.3.8. UserName Client Credentials
7.4. Working with Certificates
7.4.1. Understanding Certificates, Digital Signatures, and Encryption
7.4.2. Signing and Encrypting Messages
7.4.3. Service Certificates and Negotiation
7.4.4. Certificate Authentication
7.4.5. Certificate Authorization
7.5. Building a Claims-Based Security Model
7.5.1. Security Tokens and Claims
7.5.2. AuthorizationContext
7.5.3. Custom Claims
7.5.4. Custom Authorization Policies
7.5.5. Lab: Creating a Custom Authorization Policy
7.5.5.1. Implementing IAuthorizationPolicy
7.5.5.2. Authorizing custom claims
7.5.5.3. Applying custom security extensions
7.6. Exploring Federated Security
7.6.1. Security Token Services
7.6.2. SAML Tokens
7.6.3. Windows CardSpace
7.6.4. LAB: Working with WSFederationHttpBinding
7.6.4.1. Configuring WSFederationHttpBinding
7.6.4.2. Creating an information card in CardSpace
7.6.4.3. Evaluating CardSpace claims
7.6.5. WSFederationHttpBinding Security Features
7.7. Summary
8. Exceptions and Faults
8.1. SOAP Faults
8.1.1. Fault Versions
8.1.2. Faults and WSDL
8.2. WCF Exception Handling
8.2.1. Fault Exceptions
8.2.2. Service Exception Handling
8.2.3. Client Exception Handling
8.3. Exceptions and Debugging
8.3.1. Lab: Working with Uncaught Exceptions
8.3.2. Debugging Behavior
8.3.3. Uncaught Exceptions and SOAP Faults
8.3.4. Clients and Faulted Channels
8.4. Fault Contracts
8.4.1. Lab: Throwing Faults and Declaring Fault Contracts
8.4.2. Throwing Faults
8.4.2.1. FaultException
8.4.2.2. FaultException<T>
8.4.2.3. MessageFault
8.4.3. Declared Faults
8.4.4. Fault Contracts and Complex Types
8.4.5. Mapping MessageFault to SOAP Fault
8.4.5.1. Creating SOAP 1.1 compliant faults
8.4.6. Clients and FaultContracts
8.5. IErrorHandler
8.5.1. Lab: Intercepting Uncaught Exceptions with IErrorHandler
8.5.1.1. Implementing IErrorHandler
8.5.1.2. Configuring an error handler
8.5.1.3. Using data contracts as fault contracts
8.5.2. IErrorHandler
8.5.3. Configuring Error Handlers
8.5.3.1. Implementing IServiceBehavior
8.5.3.2. Attributes and IServiceBehavior
8.5.3.3. Extending ServiceHost
8.6. Summary
A. Setup Instructions
A.1. Database Setup
A.1.1. Choosing a Database Engine
A.1.2. Installing Database Scripts
A.1.3. Database Connection Strings
A.1.4. Database Security
A.2. ASP.NET Provider Model Setup
A.2.1. Generating ASP.NET Provider Tables
A.2.2. ASP.NET Provider Connection Strings
A.2.3. Creating Sample Users and Roles
A.3. Certificate Setup
A.3.1. Sample Certificates
A.3.2. Certificates Console
A.3.3. Importing Certificates
A.3.4. Certificate Security
A.3.5. Setting Up an SSL Certificate
A.3.5.1. Instructions for IIS 5.1 and 6.0
A.3.5.2. Instructions for IIS 7.0
A.3.6. Generating Certificates
A.4. IIS Application Directories
A.4.1. Instructions for IIS 5.1 and 6.0
A.4.2. Instructions for IIS 7.0
B. ASP.NET Meets CardSpace
B.1. Information Cards and CardSpace: A Brief Tour
B.2. Identity Metasystem Participants and Browser Flow
B.3. Let's Log In with CardSpace!
B.4. Processing the Token
B.5. Associating Cards with User Accounts
B.6. Creating a Dual Purpose Login Page
B.7. Conclusion
Index
About the Author
Colophon
← Prev
Back
Next →
← Prev
Back
Next →