What is the relationship between the bindings of a service and the channel stack?
The host application must ensure that messages being sent between the client and service conform to the security, reliability, and transactional requirements of the binding being used. The WCF runtime environment for a client application and a service provides a collection of channel objects that can perform this processing.
A channel is responsible for handling one aspect of message processing, as specified by the bindings of a service. For example, a transport channel manages communications by using a specific transport protocol, and a transaction channel controls the transactional integrity of a conversation. The WCF runtime provides built-in channels for each of the supported transport protocols. The WCF runtime also provides channels that handle the different ways that WCF can encode data, manage security, implement reliability, and perform transactions. The WCF runtime composes channels into a channel stack. All messages passing between the client and the service go through each channel in the channel stack. Each channel in the channel stack transforms the message in some way, and the output from one channel is passed as input to the next. The channel stack operates in two directions: messages received from clients across the network proceed up the channel stack to the service, and response messages sent back from the service traverse the channel stack in the opposite direction back to the network and then to the client. If a channel cannot process a message, it reports an error, an error message is sent back to the client, and the message is not processed any further.When you start a service running, the WCF runtime uses the endpoint information specified as part of the service configuration and creates a listener object for each address specified for the service. When an incoming request is received, the WCF runtime constructs a channel stack by using the binding information specified for the address and routes the incoming data from the client through the stack. If a message successfully traverses all the channels in the channel stack, the transformed request is passed to an instance of the service for processing.