Reputation: 81
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
Reputation: 13010
There isn't one built in.
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