Best way to set up a server to act as a WCF Proxy
I've got a server running some WCF services. It's located within my company's internal network. I'd like to expose its services to the internet, but I don't want to expose the server directly.
Is there a way to set up a server in our开发者_如何学C DMZ to act as a proxy to the internal server? Ideally, a solution would require minimal code on the proxy server, and not require changes to the services to be published twice.
The best way to do what you want is to use the built-in WCF 4 Routing Service. You can do a lot more than just redirect calls from another server to your internal services. This is all configuration driven so you don't need to change your service contracts or recompile any code. You can even expose services using one binding and invoke the target service with a different binding.
EDIT:
The MSDN provided samples for the RoutingService are a good starting point to see working examples of RoutingService configurations. Like more things WCF, wading through the documentation is a tedious but almost always necessary cost to learning how to use the damn thing :)
It depends upon what kind of changes you're talking about. If it's just an alternate implementation of the same service contract that redirects to the real server, the only time you would need to make changes is if the contract itself changes, not the real implementation of it (those assemblies shouldn't even be installed on the proxy server). There are aspects of WCF that let you write a service with one operation that handles a generic message and returns a generic message (OperationContract(Action="*")] public void Message Execute(Message incoming), but then you need to examine the incoming message to figure out how to forward it on.
精彩评论