Home Page Icon
Home Page
Table of Contents for
Programming WCF Services
Close
Programming WCF Services
by Juval Lowy
Programming WCF Services
Programming WCF Services
Dedication
A Note Regarding Supplemental Files
Foreword
Preface
How This Book Is Organized
Some Assumptions About the Reader
What You Need to Use This Book
Conventions Used in This Book
Using Code Examples
How to Contact Us
Safari® Enabled
Acknowledgments
1. WCF Essentials
1.1. What Is WCF?
1.2. Services
1.2.1. Services’ Execution Boundaries
1.2.1.1. WCF and location transparency
1.3. Addresses
1.3.1. TCP Addresses
1.3.2. HTTP Addresses
1.3.3. IPC Addresses
1.3.4. MSMQ Addresses
1.3.5. Peer Network Address
1.4. Contracts
1.4.1. The Service Contract
1.4.1.1. Applying the ServiceContract attribute
1.4.1.2. Names and namespaces
1.5. Hosting
1.5.1. IIS Hosting
1.5.1.1. Using Visual Studio 2005
1.5.1.2. The Web.Config file
1.5.2. Self-Hosting
1.5.2.1. Using Visual Studio 2005
1.5.2.2. Self-hosting and base addresses
1.5.2.3. Advanced hosting features
1.5.2.4. The ServiceHost<T> class
1.5.3. WAS Hosting
1.6. Bindings
1.6.1. The Standard Bindings
1.6.2. Format and Encoding
1.6.3. Choosing a Binding
1.6.4. Using a Binding
1.7. Endpoints
1.7.1. Administrative Endpoint Configuration
1.7.1.1. Using base addresses
1.7.1.2. Binding configuration
1.7.2. Programmatic Endpoint Configuration
1.7.2.1. Binding configuration
1.8. Metadata Exchange
1.8.1. Enabling Metadata Exchange Programmatically
1.8.2. The Metadata Exchange Endpoint
1.8.2.1. Adding MEX endpoints programmatically
1.8.2.2. Streamlining with ServiceHost<T>
1.8.3. The Metadata Explorer
1.9. Client-Side Programming
1.9.1. Generating the Proxy
1.9.2. Administrative Client Configuration
1.9.2.1. Binding configuration
1.9.2.2. Generating the client config file
1.9.2.3. In-proc configuration
1.9.2.4. The SvcConfigEditor
1.9.3. Creating and Using the Proxy
1.9.3.1. Closing the proxy
1.9.3.2. Call timeout
1.9.4. Programmatic Client Configuration
1.10. Programmatic Versus Administrative Configuration
1.11. WCF Architecture
1.11.1. Host Architecture
1.12. Working with Channels
1.12.1. The InProcFactory Class
1.12.1.1. Implementing InProcFactory<T>
1.13. Reliability
1.13.1. Binding and Reliability
1.13.2. Ordered Messages
1.13.3. Configuring Reliability
1.13.4. Requiring Ordered Delivery
2. Service Contracts
2.1. Operation Overloading
2.2. Contract Inheritance
2.2.1. Client-Side Contract Hierarchy
2.2.1.1. Restoring the hierarchy on the client
2.3. Service Contracts Factoring and Design
2.3.1. Contract Factoring
2.3.2. Factoring Metrics
2.4. Contract Queries
2.4.1. Programmatic Metadata Processing
2.4.2. The MetadataHelper Class
3. Data Contracts
3.1. Serialization
3.1.1. .NET Serialization
3.1.1.1. The Serializable attribute
3.1.1.2. The .NET formatters
3.1.2. The WCF Formatters
3.1.3. Data Contract via Serialization
3.2. Data Contract Attributes
3.2.1. Importing a Data Contract
3.2.2. Data Contract and the Serializable Attribute
3.2.3. Composite Data Contracts
3.2.4. Data Contract Events
3.2.4.1. Using the deserializing event
3.2.4.2. Using the deserialized event
3.3. Data Contract Hierarchy
3.3.1. Known Types
3.3.2. Service Known Types
3.3.3. Multiple Known Types
3.3.4. Configuring Known Types
3.3.5. Object and Interfaces
3.4. Data Contract Equivalence
3.4.1. Serialization Order
3.5. Versioning
3.5.1. New Members
3.5.2. Missing Members
3.5.2.1. Using the OnDeserializing event
3.5.2.2. Required members
3.5.3. Versioning Round-Trip
3.5.3.1. Schema compatibility
3.6. Enumerations
3.7. Delegates and Data Contracts
3.8. Data Sets and Tables
3.8.1. Arrays Instead of Tables
3.9. Generics
3.10. Collections
3.10.1. Concrete Collections
3.10.2. Custom Collections
3.10.3. Collection Data Contract
3.10.4. Referencing the Collection
3.10.5. Client-Side Collection
3.10.6. C# Iterators
3.10.7. Dictionaries
4. Instance Management
4.1. Behaviors
4.2. Per-Call Services
4.2.1. Benefits of Per-Call Services
4.2.2. Configuring Per-Call Services
4.2.3. Designing Per-Call Services
4.2.3.1. Per-call and performance
4.2.3.2. Cleanup operations
4.2.4. Choosing Per-Call Services
4.3. Per-Session Services
4.3.1. Configuring Private Sessions
4.3.1.1. SessionMode.Allowed
4.3.1.2. SessionMode.Required
4.3.1.3. SessionMode.NotAllowed
4.3.1.4. Binding, contract, and service behavior
4.3.1.5. Consistent configuration
4.3.2. Sessions and Reliability
4.3.3. Session ID
4.3.4. Session Termination
4.4. Singleton Service
4.4.1. Initializing a Singleton
4.4.1.1. Streamlining with ServiceHost<T>
4.4.2. Choosing a Singleton
4.5. Demarcating Operations
4.6. Instance Deactivation
4.6.1. Configuring with ReleaseInstanceMode.None
4.6.2. Configuring with ReleaseInstanceMode.BeforeCall
4.6.3. Configuring with ReleaseInstanceMode.AfterCall
4.6.4. Configuring with ReleaseInstanceMode.BeforeAndAfterCall
4.6.5. Explicit Deactivation
4.6.6. Using Instance Deactivation
4.7. Throttling
4.7.1. Configuring Throttling
4.7.1.1. Administrative throttling
4.7.1.2. Programmatic throttling
4.7.1.3. Streamlining with ServiceHost<T>
4.7.1.4. Reading throttled values
4.7.2. Throttled Connections in the Binding
5. Operations
5.1. Request-Reply Operations
5.2. One-Way Operations
5.2.1. Configuring One-Way Operations
5.2.2. One-Way Operations and Reliability
5.2.3. One-Way Operations and Sessionful Services
5.2.4. One-Way Operations and Exceptions
5.2.4.1. Per-call services and one-way exceptions
5.2.4.2. Sessionful services and one-way exceptions
5.3. Callback Operations
5.3.1. Callback Contract
5.3.2. Client Callback Setup
5.3.2.1. Duplex proxy
5.3.3. Service-Side Callback Invocation
5.3.3.1. Callback reentrancy
5.3.4. Callback Connection Management
5.3.4.1. Connection management and instance mode
5.3.5. Duplex Proxy and Type Safety
5.3.6. Duplex Factory
5.3.7. Callback Contract Hierarchy
5.3.8. Callback, Ports, and Channels
5.3.8.1. Assigning a callback address
5.3.8.2. Assigning callback address declaratively
5.4. Events
5.5. Streaming
5.5.1. I/O Streams
5.5.2. Streaming and Binding
5.5.3. Streaming and Transport
5.5.4. Stream Management
6. Faults
6.1. Errors and Exceptions
6.1.1. Exceptions and Instance Management
6.1.1.1. Per-call service and exceptions
6.1.1.2. Sessionful service and exceptions
6.1.1.3. Singleton service and exceptions
6.1.2. Faults
6.2. Fault Contracts
6.2.1. Fault Handling
6.2.2. Unknown Faults
6.2.3. Fault Debugging
6.2.3.1. Declarative exceptions inclusion
6.2.3.2. Host and exceptions diagnostics
6.2.4. Faults and Callbacks
6.2.4.1. Callbacks debugging
6.3. Error-Handling Extensions
6.3.1. Providing a Fault
6.3.1.1. Using ProvideFault( )
6.3.1.2. Exception promotion
6.3.2. Handling a Fault
6.3.2.1. The Logbook service
6.3.3. Installing Error-Handling Extensions
6.3.3.1. Error-Handling attribute
6.3.4. Host and Error Extensions
6.3.5. Callbacks and Error Extensions
6.3.5.1. Callback error-handling attribute
7. Transactions
7.1. The Recovery Challenge
7.2. Transactions
7.2.1. Transactional Resources
7.2.2. Transaction Properties
7.2.2.1. The Atomic property
7.2.2.2. The Consistent property
7.2.2.3. The Isolated property
7.2.2.4. The Durable property
7.2.3. Transaction Management
7.2.3.1. The transaction management challenge
7.2.3.2. Distributed transactions
7.2.3.3. The two-phase commit protocol
7.2.4. WCF Resource Managers
7.3. Transaction Propagation
7.3.1. Transaction Flow and Binding
7.3.2. Transaction Flow and Operation Contract
7.3.2.1. TransactionFlowOption.NotAllowed
7.3.2.2. TransactionFlowOption.Allowed
7.3.2.3. TransactionFlowOption.Mandatory
7.3.3. One-Way Calls
7.4. Transaction Protocols and Managers
7.4.1. Protocols and Bindings
7.4.2. Transaction Managers
7.4.2.1. The LTM
7.4.2.2. The KTM
7.4.2.3. The DTC
7.4.3. Transaction Manager Promotion
7.4.3.1. LTM promotion
7.4.3.2. KTM promotion
7.4.3.3. Resources and promotion
7.5. The Transaction Class
7.5.1. The Ambient Transaction
7.5.2. Local Versus Distributed Transaction
7.5.2.1. Local transaction identifier
7.5.2.2. Distributed transaction identifier
7.6. Transactional Service Programming
7.6.1. Ambient Transaction Setting
7.6.2. Transaction Propagation Modes
7.6.2.1. Client/Service transaction
7.6.2.2. Requiring transaction flow
7.6.2.3. Client transaction
7.6.2.4. Service transaction
7.6.2.5. None transaction
7.6.2.6. Choosing a service transaction mode
7.6.3. Voting and Completion
7.6.3.1. Declarative voting
7.6.3.2. Explicit voting
7.6.3.3. Terminating a transaction
7.6.4. Transaction Isolation
7.6.4.1. Isolation and transaction flow
7.6.5. Transaction Timeout
7.6.5.1. Transaction flow and timeout
7.7. Explicit Transaction Programming
7.7.1. The TransactionScope Class
7.7.1.1. TransactionScope voting
7.7.2. Transaction Flow Management
7.7.2.1. Voting inside a nested scope
7.7.2.2. TransactionScopeOption.Required
7.7.2.3. TransactionScopeOption.RequiresNew
7.7.2.4. TransactionScopeOption.Suppress
7.7.2.5. TransactionScope timeout
7.7.2.6. TransactionScope isolation level
7.7.3. Nonservice Clients
7.8. Service State Management
7.8.1. Transaction Boundary
7.8.2. State Identifier
7.9. Instance Management and Transactions
7.9.1. Per-Call Transactional Service
7.9.1.1. Transaction life cycle
7.9.2. Per-Session Transactional Service
7.9.2.1. Releasing service instance
7.9.2.2. Disabling releasing the service instance
7.9.2.3. State-aware per-session service
7.9.2.4. Stateful per-session service
7.9.2.5. Transaction life cycle
7.9.2.6. Concurrent transactions
7.9.2.7. Completing on session end
7.9.2.8. Transactional affinity
7.9.2.9. Hybrid state management
7.9.2.10. Choosing per-session transactional service
7.9.3. Transactional Singleton
7.9.3.1. Stateful singleton
7.9.4. Instancing Modes and Transactions
7.10. Callbacks
7.10.1. Callback Transaction Modes
7.10.1.1. Isolation and timeouts
7.10.2. Callback Voting
7.10.3. Using Transactional Callbacks
7.10.3.1. Out-of-band transactional callbacks
7.10.3.2. Service transactional callback
8. Concurrency Management
8.1. Instance Management and Concurrency
8.2. Service Concurrency Mode
8.2.1. ConcurrencyMode.Single
8.2.1.1. Synchronized access and transactions
8.2.2. ConcurrencyMode.Multiple
8.2.2.1. Unsynchronized access and transactions
8.2.3. ConcurrencyMode.Reentrant
8.2.3.1. Designing for reentrancy
8.2.3.2. Reentrancy and transactions
8.2.3.3. Callbacks and reentrancy
8.3. Instances and Concurrent Access
8.3.1. Per-Call Services
8.3.2. Sessionful and Singleton Services
8.4. Resources and Services
8.4.1. Deadlocked Access
8.4.2. Deadlocked Avoidance
8.5. Resource Synchronization Context
8.5.1. .NET 2.0 Synchronization Contexts
8.5.1.1. The SynchronizationContext class
8.5.1.2. Working with the synchronization context
8.5.2. UI Synchronization Context
8.5.2.1. UI access and updates
8.5.2.2. Safe controls
8.6. Service Synchronization Context
8.6.1. Hosting on the UI Thread
8.6.1.1. Accessing the form
8.6.1.2. Multiple UI threads
8.6.2. Form As a Service
8.6.2.1. The FormHost<F> class
8.6.3. UI Thread and Concurrency Management
8.6.3.1. UI responsiveness
8.6.3.2. UI thread and concurrency modes
8.7. Custom Service Synchronization Context
8.7.1. Thread-Affinity Services
8.7.2. Installing a Service Synchronization Context
8.7.2.1. The ThreadAffinityBehavior attribute
8.8. Callbacks and Client Safety
8.8.1. Callbacks with ConcurrencyMode.Single
8.8.2. Callbacks with ConcurrencyMode.Multiple
8.8.3. Callbacks with ConcurrencyMode.Reentrant
8.9. Callbacks and Synchronization Context
8.9.1. Callbacks and UI Synchronization Context
8.9.1.1. UI thread callbacks and responsiveness
8.9.1.2. UI thread callbacks and concurrency management
8.9.2. Callback Custom Synchronization Context
8.9.2.1. The CallbackThreadAffinityBehaviorAttribute
8.10. Asynchronous Calls
8.10.1. Requirements for an Asynchronous Mechanism
8.10.2. Proxy-Based Asynchronous Calls
8.10.3. Asynchronous Invocation
8.10.3.1. The IAsyncResult interface
8.10.4. Polling or Waiting for Completion
8.10.5. Completion Callbacks
8.10.5.1. Completion callback and thread safety
8.10.5.2. Passing state information
8.10.5.3. Completion callback synchronization context
8.10.6. One-Way Asynchronous Operations
8.10.7. Asynchronous Error Handling
8.10.8. Cleaning Up After End<Operation>
8.10.9. Asynchronous Calls and Transactions
8.10.10. Synchronous Versus Asynchronous Calls
9. Queued Services
9.1. Disconnected Services and Clients
9.2. Queued Calls
9.2.1. Queued Calls Architecture
9.2.2. Queued Contracts
9.2.3. Configuration and Setup
9.2.3.1. Workgroup installation and security
9.2.3.2. Creating the queue
9.2.3.3. Queue purging
9.2.3.4. Queues, services, and endpoints
9.2.3.5. Exposing metadata
9.3. Transactions
9.3.1. Delivery and Playback
9.3.1.1. Delivery transaction
9.3.1.2. Playback transaction
9.3.2. Service Transaction Configuration
9.3.2.1. Participating in playback transaction
9.3.2.2. Ignoring the playback transaction
9.3.2.3. Using a separate transaction
9.3.3. Nondurable Queues
9.4. Instance Management
9.4.1. Per-Call Queued Services
9.4.1.1. Nontransactional clients
9.4.1.2. Transactional clients
9.4.1.3. Per-call processing
9.4.2. Sessionful Queued Services
9.4.2.1. Clients and transactions
9.4.2.2. Services and transactions
9.4.3. Singleton Service
9.4.3.1. Calls and order
9.5. Concurrency Management
9.5.1. Throttling
9.6. Delivery Failures
9.6.1. The Dead-Letter Queue
9.6.2. Time to Live
9.6.3. Configuring the Dead-Letter Queue
9.6.3.1. Custom DLQ verification
9.6.4. Processing the Dead-Letter Queue
9.6.4.1. Defining the DLQ service
9.6.4.2. Failure properties
9.6.4.3. Implementing a DLQ service
9.7. Playback Failures
9.7.1. Poison Messages
9.7.2. Poison Messages Handling in MSMQ 4.0
9.7.2.1. Retry batches
9.7.2.2. ReceiveErrorHandling.Fault
9.7.2.3. ReceiveErrorHandling.Drop
9.7.2.4. ReceiveErrorHandling.Reject
9.7.2.5. ReceiveErrorHandling.Move
9.7.2.6. Configuration sample
9.7.2.7. Poison message service
9.7.3. Poison Message Handling on MSMQ 3.0
9.8. Queued Versus Connected Calls
9.8.1. Requiring Queuing
9.9. Response Service
9.9.1. Designing a Response Service Contract
9.9.1.1. Response address and method ID
9.9.1.2. Using message headers
9.9.1.3. The ResponseContext class
9.9.2. Client-Side Programming
9.9.3. Service-Side Programming
9.9.4. Response Service-Side Programming
9.9.5. Streamlining the Response Service
9.9.5.1. Streamlining the client
9.9.5.2. Streamlining the queued service
9.9.5.3. Streamlining the response service-side
9.9.6. Transactions
9.9.6.1. Using a new transaction
9.9.6.2. Response service and transactions
9.10. HTTP Bridge
9.10.1. Designing the Bridge
9.10.2. Transaction Configuration
9.10.3. Service-Side Configuration
9.10.4. Client-Side Configuration
10. Security
10.1. Authentication
10.2. Authorization
10.3. Transfer Security
10.3.1. Transfer Security Modes
10.3.1.1. None transfer security mode
10.3.1.2. Transport security
10.3.1.3. Message security
10.3.1.4. Mixed transfer security
10.3.1.5. Both transfer security
10.3.2. Transfer Security Mode Configuration
10.3.2.1. Specific bindings configuration
10.3.3. Transport Security and Credentials
10.3.4. Message Security and Credentials
10.4. Identity Management
10.5. Overall Policy
10.6. Scenario-Driven Approach
10.7. Intranet Application
10.7.1. Securing the Intranet Bindings
10.7.1.1. Transport security protection level
10.7.1.2. NetTcpBinding configuration
10.7.1.3. NetNamedPipeBinding configuration
10.7.1.4. NetMsmqBinding configuration
10.7.2. Message Protection
10.7.3. Authentication
10.7.3.1. Providing alternative Windows credentials
10.7.4. Identities
10.7.4.1. The IIdentity interface
10.7.4.2. Working with WindowsIdentity
10.7.5. The Security Call Context
10.7.6. Impersonation
10.7.6.1. Manual impersonation
10.7.6.2. Declarative impersonation
10.7.6.3. Impersonating all operations
10.7.6.4. Restricting impersonation
10.7.6.5. Using impersonation
10.7.7. Authorization
10.7.7.1. Security principal
10.7.7.2. Selecting authorization mode
10.7.7.3. Declarative role-based security
10.7.7.4. Programmatic role-based security
10.7.8. Identity Management
10.7.9. Callbacks
10.8. Internet Application
10.8.1. Securing the Internet Bindings
10.8.1.1. WSHttpBinding configuration
10.8.1.2. WSDualHttpBinding configuration
10.8.2. Message Protection
10.8.2.1. Configuring host certificate
10.8.2.2. Using the host certificate
10.8.2.3. Service certificate validation
10.8.2.4. Working with a test certificate
10.8.3. Authentication
10.8.4. Using Windows Credentials
10.8.4.1. Authorization
10.8.4.2. Identity management
10.8.5. Using the ASP.NET Providers
10.8.5.1. The credentials providers
10.8.5.2. Credentials administration
10.8.5.3. Shortcomings of Visual Studio 2005
10.8.5.4. Credentials Manager
10.8.5.5. Authentication
10.8.5.6. Authorization
10.8.5.7. Declarative role-based security
10.8.6. Identity Management
10.8.6.1. Impersonation
10.8.7. Callbacks
10.9. Business-to-Business Application
10.9.1. Securing the Business-to-Business Bindings
10.9.2. Authentication
10.9.3. Authorization
10.9.4. Identity Management
10.9.4.1. Impersonation
10.9.5. Callbacks
10.9.6. Host Security Configuration
10.10. Anonymous Application
10.10.1. Securing the Anonymous Bindings
10.10.2. Authentication
10.10.3. Authorization
10.10.4. Identity Management
10.10.4.1. Impersonation
10.10.5. Callbacks
10.11. No Security
10.11.1. Unsecuring the Bindings
10.11.2. Authentication
10.11.3. Authorization
10.11.4. Identity Management
10.11.4.1. Impersonation
10.11.5. Callbacks
10.12. Scenarios Summary
10.13. Declarative Security Framework
10.13.1. The SecurityBehaviorAttribute
10.13.1.1. Configuring intranet service
10.13.1.2. Configuring Internet service
10.13.1.3. Configuring business-to-business service
10.13.1.4. Configuring Anonymous service
10.13.1.5. Configuring No-Security service
10.13.1.6. Implementing SecurityBehaviorAttribute
10.13.2. Host and Declarative Security
10.13.3. Client-Side Declarative Security
10.13.3.1. Implementing SecurityHelper
10.13.3.2. The SecureClientBase<T> class
10.13.3.3. Secure channel factory
10.13.3.4. Duplex client and declarative security
10.13.3.5. The SecureDuplexChannelFactory<T,C> class
10.14. Security Auditing
10.14.1. Configuring Security Audits
10.14.2. Declarative Security Audit
A. Introduction to Service-Orientation
A.1. A Brief History of Software Engineering
A.1.1. Object-Orientation
A.1.2. Component-Orientation
A.2. Service-Orientation
A.2.1. Benefits of Service-Orientation
A.2.2. Service-Oriented Applications
A.3. Tenets and Principles
A.3.1. Practical Principles
A.3.2. Optional Principles
B. Publish-Subscribe Service
B.1. The Publish-Subscribe Design Pattern
B.1.1. Subscriber Types
B.2. The Publish-Subscribe Framework
B.2.1. Managing Transient Subscriptions
B.2.2. Managing Persistent Subscribers
B.2.3. Event Publishing
B.2.4. Administering Persistent Subscribers
B.2.5. Queued Publishers and Subscribers
B.2.5.1. Queued publisher
B.2.5.2. Queued subscriber
C. WCF Coding Standard
C.1. General Design Guidelines
C.2. Essentials
C.3. Service Contracts
C.4. Data Contracts
C.5. Instance Management
C.6. Operations and Calls
C.7. Faults
C.8. Transactions
C.9. Concurrency Management
C.10. Queued Services
C.11. Security
About the Author
Colophon
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Cover
Next
Next Chapter
Dedication
Programming WCF Services
Juval Lowy
Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset