A WCF consumer (client) needs to have some references to the types in the WCF host. If you are building everything on a single computer and testing, you can simply have your client project refer to the host project and then it can see the types, and can create a Binding as follows:
static void InitSomeService()
string hostAddress = System.Configuration.ConfigurationManager.AppSettings[“SomeHostUriHttp”];
EndpointAddress address = new EndpointAddress(new Uri(hostAddress));
BasicHttpBinding binding = new BasicHttpBinding();
ChannelFactory<ISomeService> factory = new ChannelFactory<ISomeService>(binding, address);
solService = factory.CreateChannel();
When you deploy this to a remote server this won’t really work because you don’t deploy the host dlls with the client, and if you were developing a client to talk to a 3rd party WCF service then you wouldn’t have the host files to deploy anyway.
So you need to create copies (or atleast representations ) of the original ISomeService interface and all the other datacontracts. You do this with the svcutil too inlcuded with Visual Studio. The easiest way is to fire up the host and run it. Then open the VS command line and type:
It will output the needed files into the same folder as svcutil, and tell you where they are. Now include those cs file in your project, and remove the references to the HOST project if you were referencing the HOST project previously.