I have a number of WCF services on my internal network which are hosted by IIS 6 using the basicHttpBinding. There are several existing applications which use these services by using the dynamic proxy "CreateChannel()" method.
I'm building a mobile application which runs outside of our network, using a cellular connection, where it is important to minimize data usage, so i'm trying to use the netTcpBinding instead of any of the http bindings.
My idea is to build a "WCF Proxy", basically a service that runs on a server that is exposed to the outside, listens using a net.tcp binding, and converts/forwards the requests to the internal http services.
Right now the code is very simple, it looks about like this...
ChannelFactory factory=new System.ServiceModel.ChannelFactory<IFooService>("FooService",new System.ServiceModel.EndpointAddress("http://internalserver/FooService.svc");
IFooService fooService=factory.CreateChannel();
ServiceHost host = new ServiceHost(fooService, new Uri[] { new Uri("net.tcp://externalserver:50001/FooService")});
I realize that this is very naive code at this point, it doesn't account for faulted channels etc, but bear with me.
The issue I'm having is that calling GetType() on fooService (which here is a proxy generated by wcf) returns IFooService, not the class of the proxy. WCF doesn't like that when creating a new service host, and I get the error "'this' type cannot be an interface itself." on the last line.
Is this just a horrible Idea? If not what's the best way to get it running? Am I going to be forced into using the svcutil generated proxies?