One of the (many) issues I encountered in creating a duplex http binding with IssuedToken security (details here) was that when using a duplex contract, the client has to open a "server" of its own to receive the callbacks from the "server" part of the contract. Unfortunately, there are a couple of fairly critical settings that you'd want to change for that client side "server" that aren't exposed via the configuration system, and have to be changed via code.
One that was really causing me problems was that for each duplex channel I opened up (and for one of our web apps, that might be 2-3 per ASP.NET page request) I had to provide a unique BaseClientAddress for each channel, which quickly ran into problems with opening too many ports (a security hassle) and insuring uniqueness of the URI's (a programming hassle). Turns out that you can ask WCF to create unique addresses for you, specific to your chosen transport in their method of uniqueness. However, you make that request by setting the ListenUri and ListenUriMode properties on the ServiceEndpoint (or the BindingContext). For the client-side "server" part of a duplex contract, that turns out to be one of those settings that isn't exposed via configuration (or much of anything else, either).
Luckily, I found an answer in the good works of Nicholas Allen (yet again). He mentioned that you could set such a property on the BindingContext for the client side of a duplex contract. Not only that, but Mike Taulty was good enough to post a sample of said solution.
There's a great summary of the solution here, but to summarize even more briefly, you have to create your own BindingElement, and inject it into the binding stack so that you can grab the BindingContext as it hastens past. Now I'm setting the ListenUri base address on a specific port, and asking WCF to do the rest by unique-ifying the URI. Not only do I not have to keep track of them myself, but I can easily control which ports are being used on the client side, which makes both IT and Security wonks really happy.
Powered by: newtelligence dasBlog 2.3.9074.18820
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.
© Copyright 2013, Patrick Cauldwell