Late bind web service

CJLeit

Freshman
Joined
Feb 1, 2006
Messages
32
Hello,

I have a project that calls a web services but it needs to call a different version of the service based on the environment I'm working in. I have this working with the code sample below but doing it this way I lose the intellisense for the web service. Is there a way to do late binding and still use intellisense?

Dim wsVendPart As Object

If bTestEnviornment = False Then
wsVendPart = New VendPart.VendPartServiceWse
Else
wsVendPart = New VendPartTest.VendPartServiceWse
End If
 
Are the two web services essentially the same but hosted on different URLs? If so you could just create a single web reference and then either change it's type to dynamic (from the properties window) which will allow you to edit the .config file and specify a url. Alternatively you could just set the URL property of the webservice at runtime to the correct service.

Generally speaking I would also suggest turning Option Strict On for VB projects and avoiding late binding altogether if possible.
 
They are essentially the same webservice just looking at a different URLs. Is there an easy way in code to chage the app.config to look at different URL's?

Thanks!

PlausiblyDamp said:
Are the two web services essentially the same but hosted on different URLs? If so you could just create a single web reference and then either change it's type to dynamic (from the properties window) which will allow you to edit the .config file and specify a url. Alternatively you could just set the URL property of the webservice at runtime to the correct service.

Generally speaking I would also suggest turning Option Strict On for VB projects and avoiding late binding altogether if possible.
 
Back
Top