I've found that the easiest way to implement this is to define your service client class programatically and pass the URI of the service in to the constructor. So your client class would look like this:
public class RuntimeServiceClient
{
public IRuntimeService service;
public RuntimeServiceClient(string uri)
{
// Setup the address of your service
EndpointAddress address = new EndpointAddress(uri);
//Setup your binding - HttpBinding, NetTcpBinding, etc.
NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport);
//Setup your binding parameters
ChannelFactory<IRuntimeService> factory = new ChannelFactory<IRuntimeService>(binding, address);
service = factory.CreateChannel();
}
}
Then, when you want to access your service on the client, you can call it like such:
string uri = "http://myservice.com/RuntimeService";
RuntimeServiceClient client = new RuntimeServiceClient(uri);
client.service.MyRuntimeServiceFunction();
Using this method, you never have to worry about keeping your client in sync with your service. As long as you maintain a reference to your IRuntimeService
interface, you can call any function exposed by the service.