title: Reporting Services Web Service, C# .NET code reuse
body: <p>I'm building a custom front-end for a collection of reporting services servers. I'm adding the ReportingServices2005 web reference to my project using;</p>
  
  <p><a href="http://server/ReportServer_InstanceName/ReportService2005.asmx?wsdl" rel="nofollow">http://server/ReportServer_InstanceName/ReportService2005.asmx?wsdl</a></p>
  
  <p>At the moment my approach is to add this reference for each server, however I'm then struggling with the code reuse aspect. The reporting services classes are then different namespaces.</p>
  
  <p>I'd like to have a method as below;</p>
  
  <pre><code>public string ListReports(Server1WebService.ReportingService2005 service) {
          service.Credentials = System.Net.CredentialCache.DefaultCredentials;
          service.Server1WebService.CatalogItem[] children = service.ListChildren("/", true);
  
          string list = String.Empty;
  
          foreach (Server1WebService.CatalogItem i in children) {
              if (!i.Hidden)
                  list += i.Name + "&lt;/br&gt;";
          }
  
          return list;
  }
  </code></pre>
  
  <p>To make this method reusable I need to know how to refactor this so that any instance of the ReportingService2005 class can be passed regardless of the namespace. At the moment I have to specify Server1WebService for all references to ReportingService2005 and CatalogItem.</p>