简体   繁体   中英

Reporting Services Web Service, C# .NET code reuse

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;

http://server/ReportServer_InstanceName/ReportService2005.asmx?wsdl

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.

I'd like to have a method as below;

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 + "</br>";
        }

        return list;
}

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.

Provided that all of the SSRS instances are the same version, You should be able to set the URL property on the proxy object:

Server1WebService server.url = new uri ("http://server/ReportServer_InstanceName/ReportService2005.asmx?wsdl"));

If you have multiple versions to deal with, you may need to provide some type of factory object that can correctly instantiate the correct version.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM