Preparing a Web Service and VB.Net client for easy deployment.

Hi
I have developed a Web Service to provide and receive data via a VB.Net client application.
One problem I have is easily preparing this for deployment. At the moment the Web Service and Client are both on my development machine, I have added a Reference to the Web Service in the Client project and the Web Service is addressed via localhost.
How can I easily get this ready for deployment. The Web Service will be deployed on a local intranet initially which I will not have access to from my development workstation. I want to change all of the occurences of localhost to the live server name but cannot without the client having a reference to the Web Service.
Ultimately, the Web Service will be placed on a server on the internet so it will need to be changed again,
Is there an easy way to just change the locations of Web Services in the client so that I can change the client once from 'localhost to the intranet machine name and then again later to the internet URL?
Thanks in advance
Hughsieman
[1043 byte] By [Hughsieman] at [2008-2-15]
# 1
The best way to do is use dynamic behavious for your web services, this will read the Url of the proxy from the application config file, which could easily change.

alternatively, you can manually assign the Url on after every instatiation of the proxy. and keep the service url in the app config file


MyService svcProxy = new MyService();
svc.Proxy = ConsifurationManager.AppSettings["MyServicelUrl"];


erymuzuan at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 2
Thanks for the reply.
Please could I trouble you to provide an example for each of these solutions. I have tried the code in your post above and cannot get it to work (I realise it is C# but I cannot get the VB.NET equivalent to work)
If I change the config file where do I change it?
Thanks again
Hughsieman
Hughsieman at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 3
Just read up on config files in the online help. There are some simple samples in there to guide you along. Posting a sample here is not as easy.

Right click your client project and choose add / add new item.

Get to the Utility category and pick "Application Configuration File", leave the name it defailts to as App.config

create a

<appSettings>

</appSettings>

section

and insert a line(s) similar to the following in it.

<add key="WSPROD" value="http://my.productionWS.companyname.com/webservicename/webservice.asmx"></add>

<add key="WSDEV" value="http://mydevmachinename/webservicename/webservice.asmx"></add>
Now, in your code, you can get the string as

dim strMyWebServiceURL as string = ConfigurationSettings.AppSettings["WSDEV"]
Change it before you build the install package to WSPROD, or come up with some bulletproof way of determining inside an if statement which setting string to use. I prefer the latter method as you then don't need to remember a damn thing when compiling.
Now, if any of the above looks funny or does not work, it's probably cause the board can't take all the special characters. Check the documentation. If you don't have it installed, install it.

RobertHousedorf at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...

.NET Development

Site Classified