添加Web引用后在Web References目录/添加引用的名称空间(例:WebPhoto)在其目录下/出现Reference.map其cs文件Reference.cs
打开该文件,删除其构造函数 例:
public PhotoAdmin() {
this.Url = global::PhotoTest.Properties.Settings.Default.PhotoTest_WebPhoto_PhotoAdmin;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
改写其构造函数内容,为:
public PhotoAdmin()
{
this.Url = "http://192.168.123.61/photoadmin/photoadmin.asmx";
}
即可以为Web服务指定固定的IP路径或域名地址,其中“http://192.168.123.61”可作为变量替换