views:

37

answers:

1

I have a list of servers, all exposing the same web service interface, that I need to call from my code.

i.e.

https://server1/service.asmx
https://server2/service.asmx
https://server3/service.asmx

My code needs to get this list of servers and invoke the same function on all of them.

I added a web references to this service, and I use "Dynamic" URL behavior. This is supposed to let me create an instance of the server proxy object, set the URI property at runtime, and then invoke the web methods, right?

But it seems the code generated by VS assumes the URI will come from the application's config file, which isn't the case for this app.

    public SharpEyeWebService() {
        this.Url = global::Company.DotNet.MyProject.Properties.Settings.Default.MyWebService;
        if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
            this.UseDefaultCredentials = true;
            this.useDefaultCredentialsSetExplicitly = false;
        }
        else {
            this.useDefaultCredentialsSetExplicitly = true;
        }
    }

Is it safe to ignore the default URL the constructor uses and employ the approach I described above?

+2  A: 

You can always set the Url, so yes this is safe. The "dynamic" you describe only influences the default Url: whether it hard-coded or comes from config.

So indeed, this is moot if you are supplying this yourself.

The awkward bit here is that it also sets UseDefaultCredentials based on what it finds - so it would be worth setting this manually so you know the value.

Marc Gravell
The same credentials config seems to be set in the URL's property setter, so I think that's ok.
Assaf Lavie