How can I set Url property of a web reference for PDA application

I am developing a PDA application using web service. This web service is developed by me. After finishing web service, I put it on 2 different servers. My PDA application has to get the IP of one of these servers from user at run time and then using the corresponding web service located on that server.

All I had tried are: (this is just a simple application that I use to express the problem) 1. Add web reference to my project by using add web reference dialog box. I browse to the URL http://10.7.7.11/WebService2/Service1.asmx . I named proxy class as "phuong".

2. Create an object of Phuong.Service1 named "ws"

3. Use web method of this web service via ws (i.e. ws.getString()). 4. Set the URL property of ws to http://10.7.7.12/WebService2/Service1.asmx

5. Then using the same web method of this web service

Result: the application can not run when invoke the web method after re-set URL property of ws.



Here is my sample code, again:



Dim ws As phuong.Service1 = New phuong.Service1 'url of the first web reference is



'http://10.7.7.11/WebService2Service1.asmx



MessageBox.Show(ws.Url & "--> " & ws.getString()) 'show the return value of the web method





ws.Url = “http://10.7.7.12/WebService2/Service1.asmx”



MessageBox.Show(ws.Url & "--> " & ws.getString()) 'ws.getString() after reset url can not

'be invoked





Best regards,

Phuong
[1698 byte] By [NTMT] at [2007-11-18 18:40:06]