Share via


Using Composite Duplex

The CompositeDuplex channel is one of the two shape-changing channels that we've included in the product for V1 (the other shape-changing channel is the OneWay channel that I've talked about in passing). CompositeDuplex is actually a concept rather than a real channel because all of the work is done by the underlying factory and listener. However, it's convenient to call CompositeDuplex a channel because it goes into your channel stack and in many ways behaves similarly to a protocol channel.

CompositeDuplex acts as a point for joining two independent underlying connections. The CompositeDuplex implementation that we provide is symmetric, which means that the underlying channel stack is the same for the factory and listener sides. It would be easy to write an asymmetric provider that is set up through code, but supporting the equivalent configuration would be a tricky issue. Our implementation just maps unassociated IInputChannel/IOutputChannel pairs to an associated IInputChannel/IOutputChannel pair. The actual shape changing that takes place here is relatively modest. This is enough though to get scenarios such as dual HTTP working. Since HTTP doesn't provide a native IInputChannel/IOutputChannel implementation, you first need to apply a OneWay channel to get the right shape.

The configurable knob on CompositeDuplexBindingElement is ClientBaseAddress. The ClientBaseAddress can be used to set up the listener side.

  • If the ListenUriBaseAddress is set, then we do not touch your configuration options for the listener at all.
  • If the ListenUriBaseAddress is not set, then we look at whether you've set the ClientBaseAddress.
    • If the ClientBaseAddress is set, then we use that for the base address and create a GUID for the relative address.
    • If the ClientBaseAddress is also not set, then we set the ListenUriMode to Unique and let the transport generate the entire address.

One restriction of using CompositeDuplex is that we do not support machine authentication. This is because the two halves of the connection may be going to different machines, so there's no guarantee that the machine messages are received from is the same as the machine that messages are going to.

Next time: Configuring an Operation to Impersonate