title: Web Service Proxy Code Generated by WSDL.exe Versus "Update Web Reference" - Should I Care?
body: <p>Using Visual Studio 2010, we have a solution with several web sites (not web application projects) and command line and winforms projects. All target .Net 2.0. Many of the projects have web references to the ASMX web services in the web sites.</p>
  
  <p>The web services change frequently, so when we compile everything, we have to manually go through all the projects and update the web service references. I have now succeeded in automating this using <a href="http://msdn.microsoft.com/en-us/library/cy2a3ybs.aspx" rel="nofollow">disco.exe</a> and <a href="http://msdn.microsoft.com/en-us/library/7h3ystb6.aspx" rel="nofollow">wsdl.exe</a>. But I'm concerned about the differences in the code generated by wsdl.exe and a manual update of the web reference in VS.</p>
  
  <p>wsdl.exe generates code like this:</p>
  
  <pre><code>public WebServiceName() {
      string urlSetting = System.Configuration.ConfigurationManager.AppSettings["WebServiceName"];
      if ((urlSetting != null)) {
          this.Url = urlSetting;
      }
      else {
          this.Url = "http://example/webservicename.asmx";
      }
  }
  </code></pre>
  
  <p>While VS generates code like this:</p>
  
  <pre><code>private bool useDefaultCredentialsSetExplicitly;
  
  public WebServiceName() {
      this.Url = global::ProjectName.Properties.Settings.Default.ProjectName_WebServiceNameWebService_WebServiceName;
      if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
          this.UseDefaultCredentials = true;
          this.useDefaultCredentialsSetExplicitly = false;
      }
      else {
          this.useDefaultCredentialsSetExplicitly = true;
      }
  }
  
  public new string Url {
      get {
          return base.Url;
      }
      set {
          if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
                      &amp;&amp; (this.useDefaultCredentialsSetExplicitly == false)) 
                      &amp;&amp; (this.IsLocalFileSystemWebService(value) == false))) {
              base.UseDefaultCredentials = false;
          }
          base.Url = value;
      }
  }
  
  public new bool UseDefaultCredentials {
      get {
          return base.UseDefaultCredentials;
      }
      set {
          base.UseDefaultCredentials = value;
          this.useDefaultCredentialsSetExplicitly = true;
      }
  }
  
  private bool IsLocalFileSystemWebService(string url) {
      if (((url == null) 
                  || (url == string.Empty))) {
          return false;
      }
      System.Uri wsUri = new System.Uri(url);
      if (((wsUri.Port &gt;= 1024) 
                  &amp;&amp; (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>Everything else is basically the same. Do I need to worry about this? It certainly means we'd have to change how the override URLs are stored in app.config and web.config files. wsdl.exe uses appSettings, VS uses configSections/applicationSettings.</p>
  
  <p>P.S.: I know ASMX is old and WCF is new. I'm stuck with this.</p>
  
  <p>UPDATE:
  Found this article that talks about the difference:</p>
  
  <p>How to share dynamic URLs across multiple Web Application Projects</p>
  
  <p><a href="http://weblogs.asp.net/bradleyb/archive/2006/05/04/445133.aspx" rel="nofollow">http://weblogs.asp.net/bradleyb/archive/2006/05/04/445133.aspx</a></p>