开发者

WCF host in Windows service, change url dynamically

I want to host a wcf service via windows service. And in client application I want to give feature by which client can chose which which wcf service he want to consume.开发者_JS百科

Scenario,

  1. Host WCF in windows service on MacA
  2. Host WCF in windows service on MacB, both services are same.
  3. Now client will have option to choose from MacA service or from MacB service.

Thanks, Mrinal Jaiswal


First of all you have to put the WCF url in the app.config of your client, next on the login form you can ask the user to specify the IP and Port of the service.

Here is a pice of code from one of my projects:

private void btnLogin_Click(object sender, EventArgs e)
{
            string url = "net.tcp://" + txtServer.Text + ":" + txtPort.Text + "/NoxService/";
            Program.Config.AppSettings.Settings["ServerAddress"].Value = url;
            Program.Config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
            //set server ip
            Program.NoxProxy.Endpoint.Address = new System.ServiceModel.EndpointAddress(ConfigurationManager.AppSettings["ServerAddress"]);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜