We are in the process of migrating legacy .Net Remoting services to WCF. After reading on the subject for a while, I stumbled upon this metadata talk and building proxies dynamically on the client: it seemed promising.
What I wanted to achieve, if possible, is to expose the services on one web application with minimal configuration (i.e., no explicit <services>
node on the config file), and build the proxies in the client (by sharing the interface) also with minimal configuration.
I know it is possible to expose metadata for all services by default, but the way this seems to work is useless, since it generates different urls for each service, and I would then need to maintain dozens of hardcoded strings on my client.
This is my current config file:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I wanted to have a single URL on the server (perhaps the base address itself, 'http://localhost/VirtualDir
') and use this endpoint to automatically resolve any service interface from the client. I came across this somewhat old post, which is more or less what I would like to achieve. At the time, there seemed to not be any way to do that gracefully.
Isn't there a way to perhaps expose a single MEX endpoint on the server, and then resolve any contract interface on it? This way I would be able to:
- store a single URL on the client
- retrieve the endpoint using the
MetadataResolver
class for a given interface - create the proxy using a
ChannelFactory<T>
using the resolved endpoint
I wanted to do this inside some kind of factory class, and use it with the Unity IoC container.
I think I can still make this work using some kind of convention to build the many real endpoint addresses using a known format. I would like to avoid that though, since it can still lead to problems.