Stripping Out Extra Endpoints
I want my service to have a set of endpoints that are conditionally enabled. Is it possible to put all of the endpoint definitions in a single configuration file rather than changing configuration depending on the conditions?
Due to the design of configuration, it's difficult for a service to pull from alternative configuration files or sources. Therefore, the approaches that rely on a single configuration file tend to work out better. The problem at hand then is to have a single, big configuration file that gets loaded by the service and a subset of that configuration file that actually gets enabled. Configuration doesn't have the concept of conditionals so we're going to need some place outside of the configuration system to perform the evaluation.
This sounds like a job for subclassing ServiceHost to override ApplyConfiguration. The base implementation will load all of the endpoints from the configuration file. Code in ApplyConfiguration can then evaluate the conditions and strip out all of the endpoints from the service description that shouldn't be enabled. This may not be as efficient as only loading the appropriate endpoints to begin with, but the process takes place only once and before any network traffic occurs. It seems more valuable to keep the implementation simple.
Next time: Server.MapPath
Comments
- Anonymous
October 04, 2007
What replacement in WCF should I be using for an ASP.NET SoapExtension? A SOAP extension is an extensibility