You are previewing Programming WCF Services, 4th Edition.
O'Reilly logo
Programming WCF Services, 4th Edition

Book Description

Programming WCF Services is the authoritative, bestselling guide to Microsoft's unified platform for developing modern service-oriented applications on Windows. Hailed as the definitive treatment of WCF, this book provides unique insight, rather than documentation, to help you learn the topics and skills you need for building WCF-based applications that are maintainable, extensible, and reusable.

Table of Contents

  1. Preface
    1. Conventions Used in This Book
      1. How This Book Is Organized
      2. Introducing Michael “Monty” Montgomery
      3. Some Assumptions About the Reader
      4. What You Need to Use This Book
    2. Safari® Books Online
    3. How to Contact Us
    4. Acknowledgments
  2. 1. WCF Essentials
    1. What Is WCF?
    2. Services
      1. Service Execution Boundaries
      2. WCF and Location Transparency
    3. Addresses
      1. TCP Addresses
      2. HTTP Addresses
      3. IPC Addresses
      4. MSMQ Addresses
      5. WebSocket Addresses
      6. UDP Addresses
    4. Contracts
      1. The Service Contract
    5. Hosting
      1. IIS Hosting
      2. Self-Hosting
      3. WAS Hosting
      4. Custom Hosting in IIS/WAS
      5. Choosing a Host
    6. Bindings
      1. The Common Bindings
      2. Choosing a Binding
      3. Additional Bindings
      4. Using a Binding
    7. Endpoints
      1. Administrative Endpoint Configuration
      2. Programmatic Endpoint Configuration
      3. Default Endpoints
      4. The Configure() Method
    8. Metadata Exchange
      1. Metadata over HTTP-GET
      2. The Metadata Exchange Endpoint
      3. The Metadata Explorer
    9. More on Behavior Configuration
    10. Client-Side Programming
      1. Generating the Proxy
      2. Administrative Client Configuration
      3. Programmatic Client Configuration
      4. The WCF-Provided Test Client
    11. Programmatic Versus Administrative Configuration
      1. Configuration Policy
    12. WCF Architecture
      1. Host Architecture
    13. Working with Channels
      1. The InProcFactory Class
    14. Transport-Level Sessions
      1. Transport Session and Binding
      2. Transport Session Termination
    15. Reliability
      1. Bindings, Reliability, and Ordered Messages
      2. Configuring Reliability
      3. Requiring Ordered Delivery
  3. 2. Service Contracts
    1. Operation Overloading
    2. Contract Inheritance
      1. Client-Side Contract Hierarchy
    3. Service Contract Factoring and Design
      1. Contract Factoring
      2. Factoring Metrics
    4. Contract Queries
      1. Programmatic Metadata Processing
      2. The MetadataHelper Class
  4. 3. Data Contracts
    1. Serialization
      1. .NET Serialization
      2. The WCF Formatters
      3. Data Contract via Serialization
    2. Data Contract Attributes
      1. Importing a Data Contract
      2. Data Contracts and the Serializable Attribute
      3. Inferred Data Contracts
      4. Composite Data Contracts
      5. Data Contract Events
      6. Shared Data Contracts
    3. Data Contract Hierarchy
      1. Known Types
      2. Service Known Types
      3. Multiple Known Types
      4. Configuring Known Types
      5. Data Contract Resolvers
      6. Objects and Interfaces
    4. Data Contract Equivalence
      1. Serialization Order
    5. Versioning
      1. New Members
      2. Missing Members
      3. Versioning Round-Trip
    6. Data Contract Factoring and Design
      1. Data Contract Design
      2. Data Contract Factoring
      3. Operation Factoring
      4. The Data Transfer Object Pattern
    7. Enumerations
    8. Delegates and Data Contracts
    9. Generics
    10. Collections
      1. Concrete Collections
      2. Custom Collections
      3. The CollectionDataContract Attribute
      4. Referencing a Collection
      5. Dictionaries
  5. 4. Instance Management
    1. Behaviors
    2. Per-Call Services
      1. Benefits of Per-Call Services
      2. Configuring Per-Call Services
      3. Per-Call Services and Transport Sessions
      4. Designing Per-Call Services
      5. Choosing Per-Call Services
    3. Per-Session Services
      1. Configuring Private Sessions
      2. Sessions and Reliability
      3. The Session ID
      4. Session Termination
    4. Singleton Service
      1. Initializing a Singleton
      2. Choosing a Singleton
    5. Demarcating Operations
    6. Instance Deactivation
      1. Configuring with ReleaseInstanceMode.None
      2. Configuring with ReleaseInstanceMode.BeforeCall
      3. Configuring with ReleaseInstanceMode.AfterCall
      4. Configuring with ReleaseInstanceMode.BeforeAndAfterCall
      5. Explicit Deactivation
      6. Using Instance Deactivation
    7. Durable Services
      1. Durable Services and Instance Management Modes
      2. Instance IDs and Durable Storage
      3. Explicit Instance IDs
      4. Instance IDs in Headers
      5. Context Bindings for Instance IDs
      6. Automatic Durable Behavior
    8. Throttling
      1. Configuring Throttling
  6. 5. Operations
    1. Request-Reply Operations
    2. One-Way Operations
      1. Configuring One-Way Operations
      2. One-Way Operations and Reliability
      3. One-Way Operations and Sessionful Services
      4. One-Way Operations and Exceptions
    3. Callback Operations
      1. The Callback Contract
      2. Client Callback Setup
      3. Service-Side Callback Invocation
      4. Callback Connection Management
      5. The Duplex Proxy and Type Safety
      6. The Duplex Factory
      7. Callback Contract Hierarchy
    4. Events
    5. Streaming
      1. I/O Streams
      2. Streaming and Binding
      3. Streaming and Transport
  7. 6. Faults
    1. Error Isolation and Decoupling
      1. Error Masking
      2. Channel Faulting
    2. Fault Propagation
      1. Fault Contracts
      2. Fault Debugging
      3. Faults and Callbacks
    3. Error-Handling Extensions
      1. Providing a Fault
      2. Handling a Fault
      3. Installing Error-Handling Extensions
      4. The Host and Error Extensions
      5. Callbacks and Error Extensions
  8. 7. Transactions
    1. The Recovery Challenge
    2. Transactions
      1. Transactional Resources
      2. Transaction Properties
      3. Transaction Management
      4. Resource Managers
    3. Transaction Propagation
      1. Transaction Flow and Bindings
      2. Transaction Flow and the Operation Contract
      3. One-Way Calls
    4. Transaction Protocols and Managers
      1. Protocols and Bindings
      2. Transaction Managers
      3. Transaction Manager Promotion
    5. The Transaction Class
      1. The Ambient Transaction
      2. Local Versus Distributed Transactions
    6. Transactional Service Programming
      1. Setting the Ambient Transaction
      2. Transaction Propagation Modes
      3. Voting and Completion
      4. Transaction Isolation
      5. Transaction Timeout
    7. Explicit Transaction Programming
      1. The TransactionScope Class
      2. Transaction Flow Management
      3. Non-Service Clients
    8. Service State Management
      1. The Transaction Boundary
    9. Instance Management and Transactions
      1. Per-Call Transactional Services
      2. Per-Session Transactional Services
      3. Transactional Durable Services
      4. Transactional Behavior
      5. Transactional Singleton Service
      6. Instancing Modes and Transactions
    10. Callbacks
      1. Callback Transaction Modes
      2. Callback Voting
      3. Using Transactional Callbacks
  9. 8. Concurrency Management
    1. Instance Management and Concurrency
    2. Service Concurrency Modes
      1. ConcurrencyMode.Single
      2. ConcurrencyMode.Multiple
      3. ConcurrencyMode.Reentrant
    3. Instances and Concurrent Access
      1. Per-Call Services
      2. Sessionful and Singleton Services
    4. Resources and Services
      1. Deadlocked Access
      2. Deadlock Avoidance
    5. Resource Synchronization Context
      1. .NET Synchronization Contexts
      2. The UI Synchronization Context
    6. Service Synchronization Context
      1. Hosting on the UI Thread
      2. A Form as a Service
      3. The UI Thread and Concurrency Management
    7. Custom Service Synchronization Contexts
      1. The Thread Pool Synchronizer
      2. Replacing the I/O Completion Thread Pool
      3. Thread Affinity
      4. Priority Processing
    8. Callbacks and Client Safety
      1. Callbacks with ConcurrencyMode.Single
      2. Callbacks with ConcurrencyMode.Multiple
      3. Callbacks with ConcurrencyMode.Reentrant
    9. Callbacks and Synchronization Contexts
      1. Callbacks and the UI Synchronization Context
      2. Callback Custom Synchronization Contexts
    10. Asynchronous Calls
      1. Requirements for an Asynchronous Mechanism
      2. Proxy-Based Asynchronous Calls
      3. Asynchronous Invocation
      4. Polling or Waiting for Completion
      5. Continuations
      6. One-Way Asynchronous Operations
      7. Asynchronous Error Handling
      8. Asynchronous Calls and Transactions
      9. Synchronous Versus Asynchronous Calls
      10. Asynchronous Service Operations
  10. 9. Queued Services
    1. Disconnected Services and Clients
    2. Queued Calls
      1. Queued Calls Architecture
      2. Queued Contracts
      3. Configuration and Setup
    3. Transactions
      1. Delivery and Playback
      2. Service Transaction Configuration
      3. Nontransactional Queues
    4. Instance Management
      1. Per-Call Queued Services
      2. Sessionful Queued Services
      3. Singleton Service
    5. Concurrency Management
      1. Throttling
    6. Delivery Failures
      1. The Dead-Letter Queue
      2. Time to Live
      3. Configuring the Dead-Letter Queue
      4. Processing the Dead-Letter Queue
    7. Playback Failures
      1. Poison Messages
      2. Poison Message Handling
    8. Queued Versus Connected Calls
      1. Requiring Queuing
    9. The Response Service
      1. Designing a Response Service Contract
      2. Client-Side Programming
      3. Queued Service-Side Programming
      4. Response Service-Side Programming
      5. Transactions
    10. The HTTP Bridge
      1. Designing the Bridge
      2. Transaction Configuration
      3. Service-Side Configuration
      4. Client-Side Configuration
  11. 10. Security
    1. Authentication
    2. Authorization
    3. Transfer Security
      1. Transfer Security Modes
      2. Transfer Security Mode Configuration
      3. Transport Security and Credentials
      4. Message Security and Credentials
    4. Identity Management
    5. Overall Policy
    6. Scenario-Driven Approach
    7. Intranet Application Scenario
      1. Securing the Intranet Bindings
      2. Constraining Message Protection
      3. Authentication
      4. Identities
      5. The Security Call Context
      6. Impersonation
      7. Authorization
      8. Identity Management
      9. Callbacks
    8. Internet Application Scenario
      1. Securing the Internet Bindings
      2. Message Protection
      3. Authentication
      4. Using Windows Credentials
      5. Using the ASP.NET Providers
      6. Identity Management
    9. Business-to-Business Application Scenario
      1. Securing the Business-to-Business Bindings
      2. Authentication
      3. Authorization
      4. Identity Management
      5. Host Security Configuration
    10. Anonymous Application Scenario
      1. Securing the Anonymous Bindings
      2. Authentication
      3. Authorization
      4. Identity Management
      5. Callbacks
    11. No Security Scenario
      1. Unsecuring the Bindings
      2. Authentication
      3. Authorization
      4. Identity Management
      5. Callbacks
    12. Scenarios Summary
    13. Declarative Security Framework
      1. The SecurityBehaviorAttribute
      2. Host-Side Declarative Security
      3. Client-Side Declarative Security
    14. Security Auditing
      1. Configuring Security Audits
      2. Declarative Security Auditing
  12. 11. The Azure Service Fabric
    1. Why Azure Service Fabric
      1. An Integrated Platform
      2. Design Consistency
      3. Programming Model Consistency
      4. Future Compatible
    2. Preparing for the Service Fabric
      1. ServiceModelEx.ServiceFabric
    3. Configuring the Service Fabric
      1. IT Operations
      2. Development
      3. Both
    4. Programming the Service Fabric
      1. The Service Programming Model
      2. Reliable Services
      3. Reliable Actors
      4. State Management
      5. Hosting
      6. The Client Programming Model
    5. Modeling the Service Fabric
      1. Modeling Approach
      2. Modeling Reliable Services
      3. Modeling Reliable Actors
      4. Modeling Hosting
      5. Testing
  13. A. Introduction to Service Orientation
    1. A Brief History of Software Engineering
      1. Object Orientation
      2. Component Orientation
    2. Service Orientation
      1. Benefits of Service Orientation
      2. Service-Oriented Applications
    3. Tenets and Principles
      1. Practical Principles
      2. Optional Principles
    4. What’s Next?
      1. A Service-Oriented Platform
  14. B. Headers and Contexts
    1. Message Headers
      1. Client-Side Header Interaction
      2. Service-Side Header Interaction
      3. Encapsulating the Headers
      4. Streamlining the Client
    2. Context Bindings
      1. Client-Side Context Binding Interaction
      2. Service-Side Context Binding Interaction
      3. Streamlining the Client
      4. Streamlining the Service
      5. Creating a Custom Context Binding
  15. C. Discovery
    1. Address Discovery
      1. Service Configuration
      2. Client-Side Steps
      3. Scopes
      4. Streamlining Discovery
      5. Ongoing Discovery
    2. Announcements
      1. Announcing Endpoints
      2. Receiving Announcements
      3. Streamlining Announcements
    3. TCP-Based Discovery
      1. The Discovery Proxy Pattern
      2. Solution Architecture
      3. TCP Discovery Contracts
      4. The Discovery Service
      5. The Discovery Service Host
      6. Discoverable Services
      7. Discovery Client
    4. TCP-Based Announcements
      1. TCP Announcements Contracts
      2. Discovery Service
      3. The Discovery Service Host
      4. Announcing Services
      5. Announcements Client
  16. D. Publish-Subscribe Service
    1. The Publish-Subscribe Design Pattern
      1. Subscriber Types
    2. The Publish-Subscribe Framework
      1. Managing Transient Subscriptions
      2. Managing Persistent Subscribers
      3. Event Publishing
      4. Administering Persistent Subscribers
      5. Queued Publishers and Subscribers
    3. Publish-Subscribe with Discovery
      1. The DiscoveryPublishService<T> Class
      2. The Publisher
      3. The Subscriber
      4. More on DiscoveryPublishService<T>
  17. E. Generic Interceptor
    1. Intercepting Service Operations
      1. The Generic Invoker
      2. Installing the Interceptor
    2. Intercepting Client Calls
    3. The Trace Interceptors
    4. Identity Stack Propagation
      1. Security Call Stack Interceptor
  18. F. WCF Coding Standard
    1. General Design Guidelines
    2. Essentials
    3. Configuration
    4. Addressing
    5. Service Contracts
    6. Data Contracts
    7. Instance Management
    8. Operations and Calls
    9. Faults
    10. Transactions
    11. Concurrency Management
    12. Queued Services
    13. Security
  19. G. ServiceModelEx Catalog
    1. CollectionExtensions
      1. Category
      2. Description
      3. See Also
    2. ArrayExtensions
      1. Category
      2. Description
      3. See Also
    3. InProcFactory<S,I>
      1. Category
      2. Description
      3. See Also
    4. WcfWrapper<S,I>
      1. Category
      2. Description
      3. See Also
    5. ServiceHost<T>
      1. Category
      2. Description
      3. See Also
    6. MetadataHelper
      1. Category
      2. Description
    7. DataContractSerializer<T>
      1. Category
      2. Description
    8. GenericResolver, GenericResolverBehaviorAttribute, GenericResolverInstaller
      1. Category
      2. Description
      3. See Also
    9. ServiceThrottleHelper
      1. Category
      2. Description
    10. IInstanceStore<ID,T>
      1. Category
      2. Description
      3. See Also
    11. FileInstanceStore<ID,T>, FilePersistenceProvider, FilePersistenceProviderFactory
      1. Category
      2. Description
      3. See Also
    12. MemoryProvider, MemoryProviderFactory
      1. Category
      2. Description
      3. See Also
    13. TransactionalMemoryStore<ID,T>, TransactionalMemoryProvider, TransactionalMemoryProviderFactory
      1. Category
      2. Description
      3. See Also
    14. TransactionalInstanceStore<ID,T>, TransactionalInstanceProvider, TransactionalInstanceProviderFactory
      1. Category
      2. Description
      3. See Also
    15. InstanceContext<T>, DuplexClientBase<T,C>, DuplexChannelFactory<T,C>
      1. Category
      2. Description
      3. See Also
    16. DebugHelper
      1. Category
      2. Description
    17. ErrorHandlerHelper
      1. Category
      2. Description
      3. See Also
    18. ErrorHandlerBehaviorAttribute, CallbackErrorHandlerBehaviorAttribute
      1. Category
      2. Description
      3. See Also
    19. ILogbookManager, LogbookManagerClient, LogbookManager
      1. Category
      2. Description
      3. See Also
    20. BindingRequirementAttribute
      1. Category
      2. Description
    21. ResourceManager, TransactionalLock
      1. Category
      2. Description
      3. See Also
    22. Transactional<T>
      1. Category
      2. Description
      3. See Also
    23. TransactionalCollection<C,T>
      1. Category
      2. Description
      3. See Also
    24. TransactionalArray<T>, TransactionalDictionary<K,T>, TransactionalLinkedList<T>, TransactionalList<T>, TransactionalQueue<T>, TransactionalSortedDictionary<K,T>, TransactionalSortedList<K,T>, TransactionalStack<T>
      1. Category
      2. Description
      3. See Also
    25. TransactionalBehaviorAttribute
      1. Category
      2. Description
      3. See Also
    26. OneWayClientBaseAsync<T>
      1. Category
      2. Description
    27. FormHost<F>
      1. Category
      2. Description
    28. SafeButton, SafeLabel, SafeListBox, SafeProgressBar, SafeStatusBar, SafeTextBox, SafeTrackBar
      1. Category
      2. Description
      3. See Also
    29. ThreadPoolSynchronizer, ThreadPoolBehaviorAttribute, CallbackThreadPoolBehaviorAttribute, ThreadPoolHelper
      1. Category
      2. Description
      3. See Also
    30. AffinitySynchronizer, ThreadAffinityBehaviorAttribute, CallbackThreadAffinityBehaviorAttribute, HostThreadAffinity
      1. Category
      2. Description
      3. See Also
    31. PrioritySynchronizer, PriorityClientBase<T>, PriorityContext, PriorityCallsBehaviorAttribute
      1. Category
      2. Description
      3. See Also
    32. AsyncContextSynchronizer, AsyncContextBehaviorAttribute, HostAsyncContextExtensions
      1. Category
      2. Description
      3. See Also
    33. QueuedServiceHelper
      1. Category
      2. Description
      3. See Also
    34. ClientResponseBase<T>, ServiceResponseBase<T>, ResponseContext
      1. Category
      2. Description
      3. See Also
    35. CredentialsManager, AspNetSqlProviderService
      1. Category
      2. Description
      3. See Also
    36. SecureClientBase<T>, SecureDuplexClientBase<T,C>, SecurityBehaviorAttribute, SecurityHelper, ServiceSecurity
      1. Category
      2. Description
      3. See Also
    37. HeaderClientBase<T,H>, HeaderChannelFactory<T,H>, GenericContext<T>
      1. Category
      2. Description
      3. See Also
    38. ContextClientBase<T>, ContextManager
      1. Category
      2. Description
      3. See Also
    39. NetNamedPipeContextBinding, NetNamedPipeContextBindingElement, NetNamedPipeContextBindingCollectionElement
      1. Category
      2. Description
      3. See Also
    40. AsyncContext, AsyncContextScope
      1. Category
      2. Description
      3. See Also
    41. DiscoveryHelper
      1. Category
      2. Description
      3. See Also
    42. DiscoveryFactory
      1. Category
      2. Description
      3. See Also
    43. AddressesContainer<T>
      1. Category
      2. Description
      3. See Also
    44. AnnouncementSink<T>
      1. Category
      2. Description
      3. See Also
    45. DiscoveredServices<T>
      1. Category
      2. Description
      3. See Also
    46. IDiscovery, IDiscoveryCallback, IAnnouncements, DiscoveryService, DiscoveryFactory, DuplexDiscoveryClient, IDiscoverySubscription, IAnnouncementsSubscription, DuplexAnnouncementSink<T>
      1. Category
      2. Description
      3. See Also
    47. PersistentSubscriptionServiceClient, IPersistentSubscriptionService, ISubscriptionService, PersistentSubscription, PublishService<T>, SubscriptionManager<T>, PersistentSubscriptionManager
      1. Category
      2. Description
      3. See Also
    48. DiscoveryPublishService<T>
      1. Category
      2. Description
      3. See Also
    49. GenericInvoker, OperationInterceptorBehaviorAttribute, ServiceInterceptorBehaviorAttribute
      1. Category
      2. Description
      3. See Also
    50. InterceptorClientBase<T>, InterceptorChannelFactory<T>
      1. Category
      2. Description
      3. See Also
    51. SecurityCallFrame, SecurityCallStack, SecurityCallStackContext, SecurityCallStackClientBase<T>, SecurityCallStackInterceptor, OperationSecurityCallStackAttribute, SecurityCallStackBehaviorAttribute
      1. Category
      2. Description
      3. See Also
    52. FabricRuntime, ActorRegistration
      1. Category
      2. Description
      3. See Also
    53. ApplicationManifestAttribute
      1. Category
      2. Description
      3. See Also
    54. ServiceTestBase
      1. Category
      2. Description
      3. See Also
    55. IActor, ActorId, ActorBase, Actor, Actor<S>, ActorProxy, ActorGarbageCollectionAttribute, ReadonlyAttribute, CompletesActorInstanceAttribute, VolatileActorStateProviderAttribute, KvsActorStateProviderAttribute, ReliableDictionaryActorStateProviderAttribute
      1. Category
      2. Description
      3. See Also
    56. IService, StatelessServiceBase, ServiceProxy, ServicePartitionClient, WcfCommunicationClient<T>, WcfCommunicationClientFactory<T>, ServiceFabricClientBase<T>, ServicePartitionResolver
      1. Category
      2. Description
      3. See Also
  20. Index