代码之家  ›  专栏  ›  技术社区  ›  Assaf Lavie

web服务URI的动态绑定

  •  2
  • Assaf Lavie  · 技术社区  · 14 年前

    我有一个服务器列表,所有服务器都公开了相同的web服务接口,我需要从代码中调用这些服务器。

    https://server1/service.asmx
    https://server2/service.asmx
    https://server3/service.asmx
    

    我的代码需要得到这个服务器列表,并在所有服务器上调用相同的函数。

    但是VS生成的代码似乎假设URI来自应用程序的配置文件,而这个应用程序不是这样的。

        public SharpEyeWebService() {
            this.Url = global::Company.DotNet.MyProject.Properties.Settings.Default.MyWebService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
    

    忽略构造函数使用的默认URL并采用上面描述的方法安全吗?

    1 回复  |  直到 14 年前
        1
  •  3
  •   Marc Gravell    14 年前

    你可以 总是 设置 Url 违约 网址 :无论是硬编码还是来自配置。

    这里的尴尬之处在于,它还设置了 UseDefaultCredentials