views:

875

answers:

1

Is it possible/how do I stop and start the HTTP MEX listener of a self hosted WCF service at runtime without affecting the primary WCF service?

(Please don't ask why I want to do this. It is a hack to get around artificial limitations imposed by someone else.)

+2  A: 
EnocNRoll
I am not completely satisfied with my solution: 1) I don't like assuming only 1 EndpointDispatcher and specifying ContractName instead of comparing a type; 2) I don't like assuming that the MEX ChannelDispatcher has 0 endpoints and that it is the only such ChannelDispatcher.
EnocNRoll
I also do not like the extension methods themselves, because of the need to embed the cast to IWCFSTate. Therefore, I might just move them into my WCFServiceHostUtils static class instead.
EnocNRoll
Thanks, this was extremely helpful. I modified my version a bit to support multiple Mex endpoints, and it works as desired.
chilltemp
I am glad! If you have any links to resources that might have helped you any further, like on a way to support multiple Mex endpoints, I would love to see that. Cheers!
EnocNRoll
I'm pretty sure that my '2 Mex endpoints' are nothing more than an artifact of my learning WCF. There is actually only 1 Mex address exposed.
chilltemp