terahex
terahex

Reputation: 81

Deploying Reporting Services solution

I am writing a Reporting Services solution for a customer. I am developing this solution on my development environment, and don't have access to the customers site. I am looking for a way to package up my Reporting Services solution. I want some type of Setup deployment package that will assist them with specifying their production data sources during installation.

Upvotes: 1

Views: 1858

Answers (1)

JamieSee
JamieSee

Reputation: 13010

There isn't one built in.

  1. You'll need to make a dll project and write a custom installer action. See Walkthrough: Creating a Custom Action for an example.
  2. Your dll will need to include a web service reference to http://SsrsServer.mydomain.tld/ReportServer/ReportService2005.asmx. See How to: Add a Reference to a Web Service.
  3. You'll need to add a custom dialog to the installer to ask for a report server deployment location. See Walkthrough: Using a Custom Action to Create a Database at Installation for an example of how to create and use a custom dialog.
  4. You'll need a custom dialog to get the folder where the reports will deploy.
  5. You'll need to programmatically change your web service reference's destination.
  6. You'll need to make the appropriate web service call to create a DataSource.
  7. You'll need to make the appropriate web service call to create a Report.
  8. You'll need to bind the Report to the DataSource.

The reporting services web service that you will need is documented at ReportingService2005 Class. Here's some sample code for the operations:

    /// <summary>
    /// Gets the reporting service SOAP client with the specified report server URL.
    /// </summary>
    /// <param name="reportServerUrl">The report server URL.</param>
    /// <returns>An instance of the reporting service SOAP client.</returns>
    internal static ReportingService2005SoapClient GetReportingService2005(Uri reportServerUrl)
    {
        EndpointAddress endPoint = new EndpointAddress(reportServerUrl);
        ReportService2005.ReportingService2005SoapClient soapClient = new ReportService2005.ReportingService2005SoapClient("ReportingService2005Soap", endPoint);
        soapClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

        return soapClient;
    }

    /// <summary>
    /// Creates the data source.
    /// </summary>
    /// <param name="reportServerUri">The report server URI.</param>
    /// <param name="parentPath">The parent path.</param>
    /// <param name="itemName">Name of the item.</param>
    /// <param name="dataSourceDefinition">The data source definition.</param>
    internal static void CreateDataSource(Uri reportServerUri, string parentPath, string itemName, string description, DataSourceDefinition dataSourceDefinition)
    {
        using (ReportingService2005SoapClient reportingService = GetReportingService2005(reportServerUri))
        {
            ServerInfoHeader serverInfo = null;
            try
            {
                Property[] props = CreateDescriptionProperty(description);
                serverInfo = reportingService.CreateDataSource(null, itemName, parentPath, true, dataSourceDefinition, props);
            }
            catch (FaultException ex)
            {
                Trace.WriteLine(string.Format("CreateDataSource {0}/{1}: {2}", parentPath, itemName, ex.Message));
            }
        }
    }

    /// <summary>
    /// Creates the report.
    /// </summary>
    /// <param name="reportServerUri">The report server URI.</param>
    /// <param name="parentPath">The parent path.</param>
    /// <param name="itemName">Name of the item.</param>
    /// <param name="reportDefinition">The report definition.</param>
    internal static void CreateReport(Uri reportServerUri, string parentPath, string itemName, string description, byte[] reportDefinition)
    {
        Warning[] warnings;

        using (ReportingService2005SoapClient reportingService = GetReportingService2005(reportServerUri))
        {
            ServerInfoHeader serverInfo = null;
            try
            {
                Property[] props = CreateDescriptionProperty(description);
                serverInfo = reportingService.CreateReport(null, itemName, parentPath, true, reportDefinition, props, out warnings);
            }
            catch (FaultException ex)
            {
                Trace.WriteLine(string.Format("CreateReport {0}/{1}: {2}", parentPath, itemName, ex.Message));
            }
        }
    }

    /// <summary>
    /// Set the report or model data sources on the reporting server from the provided data source map entries.
    /// </summary>
    /// <param name="reportServerUri">The report server URI.</param>
    /// <param name="itemPath"></param>
    /// <param name="dataSourceMapEntries"></param>
    internal static void SetItemDataSourceMap(Uri reportServerUri, string itemPath, Dictionary<string, string> dataSourceMapEntries)
    {
        DataSource[] dataSources = (from dataSourceMapEntry in dataSourceMapEntries
                                    where !string.IsNullOrEmpty(dataSourceMapEntry.Value)
                                    select ConvertDataSourceMapEntry(dataSourceMapEntry)).ToArray();

        using (ReportingService2005SoapClient reportingService = GetReportingService2005(reportServerUri))
        {
            ServerInfoHeader serverInfo = null;
            try
            {
                serverInfo = reportingService.SetItemDataSources(null, itemPath, dataSources);
            }
            catch (FaultException ex)
            {
                Trace.WriteLine(string.Format("SetItemDataSourceMap {0} {1}", itemPath, ex.Message));
            }
        }
    }

    /// <summary>
    /// Convert a data source map entry into a report server data source object.
    /// </summary>
    /// <param name="dataSourceMapEntry"></param>
    /// <returns></returns>
    private static DataSource ConvertDataSourceMapEntry(KeyValuePair<string, string> dataSourceMapEntry)
    {
        DataSource dataSource = new DataSource();
        DataSourceReference dataSourceReference = new DataSourceReference();
        dataSource.Name = dataSourceMapEntry.Key;
        dataSourceReference.Reference = dataSourceMapEntry.Value;
        dataSource.Item = dataSourceReference;
        return dataSource;
    }

Upvotes: 3

Related Questions