As transport binding developer you will have to decide which message exchange pattern your channel should or can provide. Depending on the physical characteristics of the transport, sometimes not all patterns can be provided. In general WCF supports a number of channel shapes. Channel shapes are implemented in transport bindings and support specific message exchange patterns. Unfortunately, not every channel can support every possible message exchange pattern. For example, operations with input and output parameters make no sense in queuing channels, because such operations are based on request/reply pattern, which cannot be covered over queued channel. In this post is described how WCF (Service Model) match the required channel shape.
Here is simplified procedure.
During initialization of the channel, the Service Model first analyzes the contract. That means it checks all operations specified in the contract description and depending on what messages are defined, it calculates required channel shapes for that contract.
If the contract has at least one operation which is server (provider) initiated (operation in callback contract), the channel requires duplex shape.
That means IDuplex or IDuplexSessionChannel shape. If no session is specified then no session related shapes are required.
If there is at least one operation which is client (consumer) initiated and not marked as OneWay and there is also at least one client initiated operation marked as OneWay then all four shapes IRequest, IRequestSessionChannel, IDuplex and IDuplexSessionChannel are requested. If no session is specified then no session related shapes are required.
If at least one operation is client (consumer) initiated and not marked as OneWay (even if void is return parameter) then again all four shapes IRequest, IRequestSessionChannel, IDuplex and IDuplexSessionChannel are requested. If no session is specified then no session related shapes are required.
For any other operation type IOutputChannel, IOutputSessionChannel, IRequest and IRequestSessionChannel are required. That is for example by client (consumer) initiated OneWay operation. If no session is specified then no session related shapes are required.
Because the set of operations of one contract statistically requires more than just one channel shape the Service Model has to decide which one will be used. Priorities of channel shapes are defined in the order shown in the list:
- IOutputChannel
- IRequestChannel
IDuplexChannel
By session is required then channel chapes IOutputSessionChannel, IRequestSessionChannel and IDuplexSessionChannel are used respectively.
If you want to exactly know how WCF computes channel shapes take a look in following two methods in reflector: ServiceChannelFactory.BuildChannelFactory and DispatcherBuilder.GetSupportedChannelTypes.
Posted
Mar 14 2007, 12:36 AM
by
Damir Dobric