Home Page Icon
Home Page
Table of Contents for
Cover
Close
Cover
by Juval Lowy
Programming WCF Services, 2nd Edition
Programming WCF Services, Second Edition
Dedication
A Note Regarding Supplemental Files
Forewords
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Ā® Books Online
Acknowledgments
1. WCF Essentials
What Is WCF?
Services
Service Execution Boundaries
WCF and location transparency
Addresses
TCP Addresses
HTTP Addresses
IPC Addresses
MSMQ Addresses
Peer Network Addresses
Contracts
The Service Contract
Applying the ServiceContract attribute
Names and namespaces
Hosting
IIS 5/6 Hosting
Using Visual Studio 2008
The Web.Config file
Self-Hosting
Using Visual Studio 2008
Self-hosting and base addresses
Advanced hosting features
The ServiceHost<T> class
WAS Hosting
Custom Hosting in IIS/WAS
Bindings
The Common Bindings
Format and encoding
Choosing a Binding
Additional Bindings
Using a Binding
Endpoints
Administrative Endpoint Configuration
Using base addresses
Binding configuration
Programmatic Endpoint Configuration
Binding configuration
Metadata Exchange
Enabling Metadata Exchange Administratively
Enabling Metadata Exchange Programmatically
The Metadata Exchange Endpoint
Adding MEX endpoints programmatically
Streamlining with ServiceHost<T>
The Metadata Explorer
Client-Side Programming
Generating the Proxy
Generating the proxy using SvcUtil
Administrative Client Configuration
Binding configuration
Generating the client config file
In-proc configuration
The SvcConfigEditor
Working with the proxy
Closing the proxy
Call timeout
Programmatic Client Configuration
The WCF-Provided Test Client
Programmatic Versus Administrative Configuration
WCF Architecture
Host Architecture
Working with Channels
The InProcFactory Class
Implementing InProcFactory<T>
Transport-Level Sessions
Transport Session and Binding
Transport Session Termination
Reliability
Bindings, Reliability, and Ordered Messages
Configuring Reliability
Requiring Ordered Delivery
2. Service Contracts
Operation Overloading
Contract Inheritance
Client-Side Contract Hierarchy
Restoring the hierarchy on the client
Service Contract Factoring and Design
Contract Factoring
Factoring Metrics
Contract Queries
Programmatic Metadata Processing
The MetadataResolver class
The MetadataHelper Class
3. Data Contracts
Serialization
.NET Serialization
The Serializable attribute
The NonSerialized attribute
The .NET formatters
The WCF Formatters
Data Contract via Serialization
Data Contract Attributes
Importing a Data Contract
Data Contracts and the Serializable Attribute
Inferred Data Contracts
Composite Data Contracts
Data Contract Events
Using the deserializing event
Using the deserialized event
Shared Data Contracts
Data Contract Hierarchy
Known Types
Service Known Types
Multiple Known Types
Configuring Known Types
Objects and Interfaces
Data Contract Equivalence
Serialization Order
Versioning
New Members
Missing Members
Using the OnDeserializing event
Required members
Versioning Round-Trip
Schema compatibility
Enumerations
Delegates and Data Contracts
Data Sets and Tables
Using Arrays Instead of Tables
Converting legacy data tables
Converting new data tables
Using LINQ to SQL
Generics
Collections
Concrete Collections
Custom Collections
The CollectionDataContract Attribute
Referencing a Collection
Dictionaries
4. Instance Management
Behaviors
Per-Call Services
Benefits of Per-Call Services
Configuring Per-Call Services
Per-Call Services and Transport Sessions
Designing Per-Call Services
Per-call services and performance
Cleanup operations
Choosing Per-Call Services
Per-Session Services
Configuring Private Sessions
SessionMode.Allowed
SessionMode.Required
SessionMode.NotAllowed
Bindings, contracts, and service behavior
Consistent configuration
Sessions and Reliability
The Session ID
Session Termination
Singleton Service
Initializing a Singleton
Streamlining with ServiceHost<T>
Choosing a Singleton
Demarcating Operations
Instance Deactivation
Configuring with ReleaseInstanceMode.None
Configuring with ReleaseInstanceMode.BeforeCall
Configuring with ReleaseInstanceMode.AfterCall
Configuring with ReleaseInstanceMode.BeforeAndAfterCall
Explicit Deactivation
Using Instance Deactivation
Durable Services
Durable Services and Instance Management Modes
Initiating and terminating
Instance IDs and Durable Storage
Explicit Instance IDs
Instance IDs in Headers
Context Bindings for Instance IDs
Using the standard ID for context binding
Automatic Durable Behavior
The durable service behavior attribute
The durable operation behavior attribute
Programmatic instance management
Persistence providers
Custom persistence providers
The SQL Server persistence provider
Throttling
Configuring Throttling
Administrative throttling
Programmatic throttling
Streamlining with ServiceHost<T>
Reading throttle values
Throttled Connections in the Binding
5. Operations
Request-Reply Operations
One-Way Operations
Configuring One-Way Operations
One-Way Operations and Reliability
One-Way Operations and Sessionful Services
One-Way Operations and Exceptions
Callback Operations
The Callback Contract
Client Callback Setup
Duplex proxies
Service-Side Callback Invocation
Callback reentrancy
Callback Connection Management
Connection management and instance mode
The Duplex Proxy and Type Safety
The Duplex Factory
Callback Contract Hierarchy
Callbacks, Ports, and Channels
Assigning a callback address
Assigning the callback address declaratively
Events
Streaming
I/O Streams
Streaming and Binding
Streaming and Transport
Stream Management
6. Faults
Error Isolation and Decoupling
Error Masking
Channel Faulting
Closing the proxy and the using statement
Exceptions and instance management
Fault Propagation
Fault Contracts
Fault handling
Faults and channels
Fault Debugging
Including exceptions declaratively
Host and exception diagnostics
Exception extraction
Faults and Callbacks
Callback debugging
Error-Handling Extensions
Providing a Fault
Using ProvideFault( )
Exception promotion
Handling a Fault
The logbook service
Installing Error-Handling Extensions
The ErrorHandlerBehavior attribute
The Host and Error Extensions
Callbacks and Error Extensions
The CallbackErrorHandlerBehavior attribute
7. Transactions
The Recovery Challenge
Transactions
Transactional Resources
Transaction Properties
The atomic property
The consistent property
The isolated property
The durable property
Transaction Management
The transaction management challenge
Distributed transactions
The two-phase commit protocol
WCF Resource Managers
Transaction Propagation
Transaction Flow and Bindings
Transaction Flow and the Operation Contract
TransactionFlowOption.NotAllowed
TransactionFlowOption.Allowed
TransactionFlowOption.Mandatory
One-Way Calls
Transaction Protocols and Managers
Protocols and Bindings
Transaction Managers
The LTM
The KTM
The DTC
Transaction Manager Promotion
LTM promotion
KTM promotion
Resources and promotion
The Transaction Class
The Ambient Transaction
Local Versus Distributed Transactions
The local transaction identifier
The distributed transaction identifier
Transactional Service Programming
Setting the Ambient Transaction
Transaction Propagation Modes
Client/Service transaction mode
Requiring transaction flow
Client transaction mode
Service transaction mode
None transaction mode
Choosing a service transaction mode
Voting and Completion
Declarative voting
Explicit voting
Terminating a transaction
Transaction Isolation
Isolation and transaction flow
Transaction Timeout
Transaction flow and timeout
Explicit Transaction Programming
The TransactionScope Class
TransactionScope voting
Transaction Flow Management
Voting inside a nested scope
TransactionScopeOption.Required
TransactionScopeOption.RequiresNew
TransactionScopeOption.Suppress
TransactionScope timeout
TransactionScope isolation level
Non-Service Clients
Service State Management
The Transaction Boundary
Instance Management and Transactions
Per-Call Transactional Services
The transaction lifecycle
Per-Session Transactional Services
Releasing the service instance
Disabling releasing the service instance
State-aware per-session services
Stateful per-session services
Transaction lifecycle
Concurrent transactions
Completing on session end
Transactional affinity
Hybrid state management
Transactional Durable Services
Instance ID management
Transactional Behavior
In-proc transactions
Transactional Singleton Service
Stateful singleton service
Instancing Modes and Transactions
Callbacks
Callback Transaction Modes
Isolation and timeouts
Callback Voting
Using Transactional Callbacks
Out-of-band transactional callbacks
Service transactional callbacks
8. Concurrency Management
Instance Management and Concurrency
Service Concurrency Modes
ConcurrencyMode.Single
Synchronized access and transactions
ConcurrencyMode.Multiple
Unsynchronized access and transactions
ConcurrencyMode.Reentrant
Designing for reentrancy
Reentrancy and transactions
Callbacks and reentrancy
Instances and Concurrent Access
Per-Call Services
Sessionful and Singleton Services
Resources and Services
Deadlocked Access
Deadlock Avoidance
Resource Synchronization Context
.NET Synchronization Contexts
The SynchronizationContext class
Working with the synchronization context
The UI Synchronization Context
UI access and updates
Safe controls
Service Synchronization Context
Hosting on the UI Thread
Accessing the form
Multiple UI threads
A Form As a Service
The FormHost<F> class
The UI Thread and Concurrency Management
UI responsiveness
The UI thread and concurrency modes
Custom Service Synchronization Contexts
The Thread Pool Synchronizer
Declaratively attaching a custom synchronization context
Thread Affinity
The host-installed synchronization context
Priority Processing
Callbacks and Client Safety
Callbacks with ConcurrencyMode.Single
Callbacks with ConcurrencyMode.Multiple
Callbacks with ConcurrencyMode.Reentrant
Callbacks and Synchronization Contexts
Callbacks and the UI Synchronization Context
UI thread callbacks and responsiveness
UI thread callbacks and concurrency management
Callback Custom Synchronization Contexts
Callback thread affinity
Asynchronous Calls
Requirements for an Asynchronous Mechanism
Proxy-Based Asynchronous Calls
Asynchronous Invocation
The IAsyncResult interface
Asynchronous calls and transport sessions
Polling or Waiting for Completion
Completion Callbacks
Completion callbacks and thread safety
Passing state information
Completion callback synchronization context
One-Way Asynchronous Operations
Asynchronous Error Handling
Asynchronous calls and timeouts
Cleaning up after End<Operation>( )
Asynchronous Calls and Transactions
Synchronous Versus Asynchronous Calls
9. Queued Services
Disconnected Services and Clients
Queued Calls
Queued Calls Architecture
Queued Contracts
Configuration and Setup
Workgroup installation and security
Creating the queue
Queue purging
Queues, services, and endpoints
Exposing metadata
WAS hosting
Transactions
Delivery and Playback
The delivery transaction
The playback transaction
Service Transaction Configuration
Participating in the playback transaction
Ignoring the playback transaction
Using a separate transaction
Nontransactional Queues
Instance Management
Per-Call Queued Services
Nontransactional clients
Transactional clients
Per-call processing
Sessionful Queued Services
Clients and transactions
Services and transactions
Singleton Service
Calls and order
Concurrency Management
Throttling
Delivery Failures
The Dead-Letter Queue
Time to Live
Configuring the Dead-Letter Queue
Custom DLQ verification
Processing the Dead-Letter Queue
Defining the DLQ service
Failure properties
Implementing a DLQ service
Playback Failures
Poison Messages
Poison Message Handling in MSMQ 4.0
Retry batches
ReceiveErrorHandling.Fault
ReceiveErrorHandling.Drop
ReceiveErrorHandling.Reject
ReceiveErrorHandling.Move
Configuration sample
Poison message service
Poison Message Handling in MSMQ 3.0
Queued Versus Connected Calls
Requiring Queuing
The Response Service
Designing a Response Service Contract
Response address and method ID
The ResponseContext class
Client-Side Programming
Using ResponseClientBase<T>
Queued Service-Side Programming
Response Service-Side Programming
Transactions
Using a new transaction
Response service and transactions
The HTTP Bridge
Designing the Bridge
Transaction Configuration
Service-Side Configuration
Client-Side Configuration
10. Security
Authentication
Authorization
Transfer Security
Transfer Security Modes
None transfer security mode
Transport transfer security mode
Message transfer security mode
Mixed transfer security mode
Both transfer security mode
Transfer Security Mode Configuration
Specific binding configurations
Transport Security and Credentials
Message Security and Credentials
Identity Management
Overall Policy
Scenario-Driven Approach
Intranet Application Scenario
Securing the Intranet Bindings
Transport security protection level
NetTcpBinding configuration
NetNamedPipeBinding configuration
NetMsmqBinding configuration
Constraining Message Protection
Authentication
Providing alternative Windows credentials
Identities
The IIdentity interface
Working with WindowsIdentity
The Security Call Context
Impersonation
Manual impersonation
Declarative impersonation
Impersonating all operations
Restricting impersonation
Avoiding impersonation
Authorization
The security principal
Selecting an authorization mode
Declarative role-based security
Programmatic role-based security
Identity Management
Callbacks
Internet Application Scenario
Securing the Internet Bindings
WSHttpBinding configuration
WSDualHttpBinding configuration
Message Protection
Configuring the host certificate
Using the host certificate
Service certificate validation
Working with a test certificate
Authentication
Using Windows Credentials
Authorization
Identity management
Using the ASP.NET Providers
The credentials providers
Credentials administration
Shortcomings of Visual Studio 2008
Credentials Manager
Authentication
Authorization
Declarative role-based security
Identity Management
Impersonation
Callbacks
Business-to-Business Application Scenario
Securing the Business-to-Business Bindings
Authentication
Authorization
Identity Management
Impersonation
Callbacks
Host Security Configuration
Anonymous Application Scenario
Securing the Anonymous Bindings
Authentication
Authorization
Identity Management
Impersonation
Callbacks
No Security Scenario
Unsecuring the Bindings
Authentication
Authorization
Identity Management
Impersonation
Callbacks
Scenarios Summary
Declarative Security Framework
The SecurityBehaviorAttribute
Configuring an intranet service
Configuring an Internet service
Configuring a business-to-business service
Configuring an anonymous service
Configuring a no-security service
Implementing the SecurityBehavior attribute
Host-Side Declarative Security
Client-Side Declarative Security
Implementing SecurityHelper
The SecureClientBase<T> class
Secure channel factory
Duplex clients and declarative security
Extensions for the duplex factory
Security Auditing
Configuring Security Audits
Declarative Security Auditing
A. Introduction to Service-Orientation
A Brief History of Software Engineering
Object-Orientation
Component-Orientation
Off-the-shelf plumbing
Service-Orientation
Benefits of Service-Orientation
Service-Oriented Applications
Tenets and Principles
Practical Principles
Optional Principles
What's Next?
A Service-Oriented Platform
Every class as a service
B. Headers and Contexts
Message Headers
Client-Side Header Interaction
Service-Side Header Interaction
Encapsulating the Headers
The GenericContext<T> helper class
Streamlining the Client
The HeaderClientBase<T,H> proxy class
Context Bindings
Client-Side Context Binding Interaction
Service-Side Context Binding Interaction
Streamlining the Client
Streamlining the Service
Creating a Custom Context Binding
Implementing NetNamedPipeContextBinding
C. Publish-Subscribe Service
The Publish-Subscribe Design Pattern
Subscriber Types
The Publish-Subscribe Framework
Managing Transient Subscriptions
Managing Persistent Subscribers
Event Publishing
Administering Persistent Subscribers
Singleton subscriber
Queued Publishers and Subscribers
Queued publisher
Queued subscriber
D. Code-Access Security
Code-Access Support in .NET 3.5
Partially Trusted Clients
Client-Side Demands
Suppressing demands with PartialTrustClientBase<T>
Raw WCF demands with PartialTrustClientBase<T>
Structured demands with PartialTrustClientBase<T>
Analyzing the demands of PartialTrustClientBase<T>.Invoke( )
Implementing client-side structured demands
Partially Trusted Services
AppDomainHost
Implementing AppDomainHost
Partially Trusted Hosts
Structured Host-Side Security Demands
Implementing structured host demands
Additional aspects of AppDomainHost
E. Generic Interceptor
Intercepting Service Operations
The Generic Invoker
Installing the Interceptor
Intercepting Client Calls
The Trace Interceptors
Identity Stack Propagation
Security Call Stack Interceptor
F. WCF Coding Standard
General Design Guidelines
Essentials
Service Contracts
Data Contracts
Instance Management
Operations and Calls
Faults
Transactions
Concurrency Management
Queued Services
Security
G. ServiceModelEx Catalog
CollectionExtensions
ArrayExtensions
AppDomainHost
InProcFactory
ServiceHost<T>
MetadataHelper
DataContractSerializer<T>
DataTableHelper
ServiceThrottleHelper
IInstanceStore<ID,T>
FileInstanceStore<ID,T>, FilePersistenceProvider, FilePersistenceProviderFactory
MemoryProvider, MemoryProviderFactory
TransactionalMemoryStore<ID,T>, TransactionalMemoryProvider, TransactionalMemoryProviderFactory
TransactionalInstanceStore<ID,T>, TransactionalInstanceProvider, TransactionalInstanceProviderFactory
InstanceContext<T>, DuplexClientBase<T,C>, DuplexChannelFactory<T,C>
WsDualProxyHelperCallbackBaseAddressBehaviorAttribute
DebugHelper
ErrorHandlerHelper
ErrorHandlerBehaviorAttribute, CallbackErrorHandlerBehaviorAttribute
ILogbookManager, LogbookManagerClient, LogbookManager
BindingRequirementAttribute
ResourceManager, TransactionalLock
Transactional<T>
TransactionalCollection<C,T>
TransactionalArray<T>, TransactionalDictionary<K,T>, TransactionalLinkedList<T>, TransactionalList<T>, TransactionalQueue<T>, TransactionalSortedDictionary<K,T>, Tr
TransactionalBehaviorAttribute
FormHost<F>
SafeButton, SafeLabel, SafeListBox, SafeProgressBar, SafeStatusBar, SafeTextBox, SafeTrackBar
ThreadPoolSynchronizer, ThreadPoolBehaviorAttribute, CallbackThreadPoolBehaviorAttribute, ThreadPoolHelper
AffinitySynchronizer, ThreadAffinityBehaviorAttribute, CallbackThreadAffinityBehaviorAttribute, HostThreadAffinity
PrioritySynchronizer, PriorityClientBase<T>, PriorityContext, PriorityCallsBehaviorAttribute
QueuedServiceHelper
ResponseClientBase<T>, ResponseScope<T>, ResponseContext
CredentialsManager, AspNetSqlProviderService
SecureClientBase<T>, SecureDuplexClientBase<T,C>, SecurityBehaviorAttribute, SecurityHelper, ServiceSecurity
HeaderClientBase<T,H>, GenericContext<T>
ContextClientBase<T>, ContextManager
NetNamedPipeContextBinding, NetNamedPipeContextBindingElement, NetNamedPipeContextBindingCollectionElement
PersistentSubscriptionServiceClient, IPersistentSubscriptionService, ISubscriptionService, PersistentSubscription, PublishService<T>, SubscriptionManager<T>, PersistentSubscriptionManager
PartialTrustClientBase<T>, PartialTrustDuplexClientBase<T,C>, CodeAccessSecurityHelper
GenericInvoker, OperationInterceptorBehaviorAttribute, ServiceInterceptorBehaviorAttribute
InterceptorClientBase<T>
SecurityCallFrame, SecurityCallStack, SecurityCallStackContext, SecurityCallStackClientBase<T>, SecurityCallStackInterceptor, OperationSecurityCallStackAttribute, SecurityCallStackBehaviorAttrib
Index
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
Next
Next Chapter
Programming WCF Services, Second Edition
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