Intercept calls intended for another machine with a local WCF service
I'm pretty new to WCF, so this may be a stupid question, but I am wondering if there is a way to configure a WCF service so that it "intercepts" calls intended for another machine. Essentially I'd like a call (through a browser) executed on MachineA like: "http://MachineB/MyService" to actually be handled on MachineA (provided my service is running on MachineA).
The idea would be if the user has not installed the service, the call "falls through" to MachineB, where they'll be able to install it. Once it's i开发者_开发百科nstalled, though, MachineA catches all of these subsequent calls and handles them.
I can totally see how this wouldn't be doable (without, say, hacking the machines hosts file), but I'm hoping maybe there's some WCF magic I don't know about that could enable this sort of scenario?
This sounds like a use case for the WCF RoutingService described in this article. Its part of WCF so unless you want to add custom behaviors, you just need to create & deploy config files. We added a custom logging behavior to interface into an existing logging infrastructure for troubleshooting potential communication issues but if you rely on WCF tracing, you don't even need that.
Sixto's routing solution is more elegant, but if you're using a pre-4.0 framework version, a mesage inspector on the client side or the dispatch side, or even an error handler on the dispatch side, might be "stretch" solutions (they'll get the jbo done, but not in the ideal way). See this extremely long article and this article that talks about both message inspectors and error handlers; it's a good enough starting point to figure out whehter those options will work for you.
精彩评论