tags:

views:

146

answers:

2

Hi! I need to deploy a WCF service where the user specifies some configuration data. Let me explain: the service connects to a web server and the user should specify IP and port of that server. How could I do it?

A solution could be to develop a tool which allows the user to create the configuration file and to "say" the service where to get it back.

So basically create installation packages with the service and the configuration file.

Thanks Federico

A: 

You can change the service endpoint IP address, etc. at runtime in the client program, so popping up a dialog at any point before connecting to the web service and asking the user for the IP address, etc. should work just fine, no need to jump through install package/config hoops unless you want to. Here's some code that I yanked from one of my blog posts that does pretty close to what you need:

ServiceReference1.Service1Client oneService1Client = new ServiceReference1.Service1Client();
oneService1Client.Endpoint.Address = new System.ServiceModel.EndpointAddress(
    new Uri(oneService1Client.Endpoint.Address.Uri.ToString().Replace("localhost", "127.0.0.1.")),
        oneService1Client.Endpoint.Address.Identity,
        oneService1Client.Endpoint.Address.Headers);
Michael Maddox
A: 

Thanks! In order to give to the service the IP and the port of the webserver I could create a custom constructor using the InstanceContext :)

Thanks! Federico

Federico Degrandis