现在的位置: 首页 > 综合 > 正文

项目添加Web引用,为Web服务赋IP地址或域名

2012年01月16日 ⁄ 综合 ⁄ 共 648字 ⁄ 字号 评论关闭

添加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”可作为变量替换

抱歉!评论已关闭.