Share via


Whats new in Orcas for PeerChannel : Manual addressing options.

V1 of PeerChannel didnt have any support for manual addressing. In fact, the addressing headers are overwritten by the underlying TCP when the PeerChannel passed the message along to the transport. The way PeerChannel preserved the applications's addressing was by making copies and reapplying those to the message before delivering to the application's service runtime on the receiving end.

Some interesting scenarios like Discovery needed a slightly different treatment of addressing headers from PeerChannel. One of the cool scenarios is to layer Discovery over PeerChannel with a CompositeDuplex, where the request is sent over PeerChannel in the outgoing binding, and the responses are handled by 1:1 conections in the incoming binding. pretty cool!

To Support this end-to-end, PeerChannel needed to resurface the application's To header on the receiving side exactly as set by the sender. This To (which could be different from Via) is used by the Discovery layer to route the message to the appropriate application endpoint.

Starting with Orcas, PeerChannel supports this kind of special manual-addressing like semantics. you can open a create host's endpoint with different To and Via values if your application needs this support. On the other hand, on the client side, you can attach a Via behavior (or use the appropriate variation that took To and Via) to open a proxy that stamped To and Via differently.

For example, you could do the following on the client side, to set a different via:

**

EndpointAddress

epaTo = newEndpointAddress(newUri(to1)); Program context = newProgram("0");DuplexChannelFactory<ITestDuplexChannel> cf = null;NetPeerTcpBinding binding = newNetPeerTcpBinding();

cf =

newDuplexChannelFactory<ITestDuplexChannel>(context, binding, epaTo);

cf.Endpoint.Behaviors.Add(

newClientViaBehavior(via));

cf.Open();

On the service side, you can add a PeerChannel service endpoint to a serivce host and set the ListenUri as follows:

ServiceHost host1 = newServiceHost(newProgram("ServiceHost1" ));

ServiceEndpoint sep1 = host1.AddServiceEndpoint(typeof(ITest ), binding, epaTo);

sep1.ListenUri = via;

host1.Open();

This new behavior does not require flipping any switches or tweaking settings. It is available straight out-of-the-box.