朋友咨询相关问题,走了一天的弯路,呵呵。尽信书不如无书。实际上简单得很。。。
Dim DoIt As New LdWebService.LdService
DoIt.Url = "http://。。。/LdWebService/LdService.asmx"
Back = DoIt.GetConnectionString(My.Settings.ApplicationCode, My.Settings.ApplicationFlag)
也可以和方法三配合,将Url指向一个全局变量
这样全局声明,登录的时候根据用户选择的Url进行实例化,然后用就是了。
//Reference.vb
增加一个方法,就可以很方便的实例化的时候,修改连接了
Public Sub New(ByVal Url As String)
MyBase.New()
Me.Url = Url
If (Me.IsLocalFileSystemWebService(Me.Url) = True) Then
Me.UseDefaultCredentials = True
Me.useDefaultCredentialsSetExplicitly = False
Else
Me.useDefaultCredentialsSetExplicitly = True
End If
End Sub
调用方法:
Dim
DoIt As New MyWeb.LdService("
新地址.asmx"
)
方法
1
:
wsdl http://localhost/myservice.asmx?wsdl
得到一个代理类 .
修改构造函数里面的
this.url = "Http://localhost/myservice.asmx";
--> this.url = ConfigurationSettings.AppSettings["WebServiceUrl"];
配置文件添加配置项 WebServiceUrl
得到一个代理类 .
修改构造函数里面的
this.url = "Http://localhost/myservice.asmx";
--> this.url = ConfigurationSettings.AppSettings["WebServiceUrl"];
配置文件添加配置项 WebServiceUrl
方法2:可以用操作文本的形式,强行改写app.config
方法3:修改Reference.vb中的New,改写Url属性来源。
Public Sub New()
…………
Me.Url = Global.MyTryIt.My.MySettings.Default.MyTryIt_MyWeb_LdService
………
End Sub
方法四:
http://topic.csdn.net/t/20041209/13/3629871.html