Code to handle WebService URL being redirected to new URL

I have a VB.Net windows client code that is connecting to a webservice URL, say:

The URL is stored in the app.config file. Then a Redirection is setup in the IIS Webserver, say the above URL is now being redirected to a new URL:

My VB project has a Web Reference to myProject.WebService, so it is reference thru-out the application.
Currently my code stands like this:

        Dim proxyWebService As myProject.WebService.SampleService
        'Reading off the app.config
        proxyWebService.Url = System.Configuration.ConfigurationManager.AppSettings("SampleServiceURL")

            ' then I call any Web Methods on the Webservice
            strOutputXML = proxyWebService.mySampleMethod()
How can I make my code flexible to handle this future change of the URL, without manually changing the app.config value.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If the URL changes, then that has to be communicated to the application somehow.  So your only options are hardcoding it or retrieving it from a settings store.  

In our applications, we find the app.config file too cryptic for client consumption so we use our own equivalent and provide GUI functions to configure it.  You could do the same or even provide a GUI to configure the app.config file.

If you use your own settings store for the url,  then you need to instantiate your web service (which will read the url from the app.config file) and then set the Url from your own settings store.

We created a simple Application factory class for the client application which generated configure instances of each web service using settings retrieved from our own settings file.

Hope this is useful.

conrabaAuthor Commented:
It is a windows app w/c consumes the webservice, though I forgot to mention this is deployed to disconnected laptops w/c only gets internet connection only when plugged-in, just to convey a manual update to such close to a hundred users is a nightmare.  

I see where you are going at but to the new URL is basically unknown since the environment hasn’t been created yet (might be next year), hence the need of flexibility on code.

I figured, handling a redirect first to obtain a webservice connection will allow them to continue, and behind the scenes will be any application update firing-up, including an app.config update. Then for a certain point, the original URL will then seize to exist.
Regardless, the requirement is that the windows client needs to access one webservice URL.
conrabaAuthor Commented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

conraba, that's a bad solution.
you should be setting webservice.Url property to dynamically change the destination.
conrabaAuthor Commented:
@meraydin2, you are exactly correct,  the end goal was to assign the  new URL value. If you read carefully the solution on the other link, it was trying to get the new URL. Although it did not show assigning the new URL, it clearly shows how to get the new one.

If you have a better solution, please post it here so there is an alternative.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.