I was
searching for automated deployment of .rdl [report definition language] files
on SSRS reporting server 2012. Everywhere I found the reporting service example
which was prior to 2012. Following code illustrates how we can deploy .rdl
files to SSRS 2012.
SSRS
2012 report service has URL same as 2010. Therefore the report service URL will
be as follows –
http://ServerNameHavingSQL2012:PortNumber/reportserver/reportservice2010.asmx
If
you have hosted reporting service on default port 80 then you don’t need to
provide PortNumber in above URL. I have written a class to make automated
deployment of .rdl files. Let’s call it as RDLDeployer. I have added a public
method which takes string parameter. This string parameter can be the path of
.rdl file to be deployed on SSRS 2012.
First
add reference of SSRS web service in your application. Then use following code
to deploy the .rdl file on report server 2012.
1.
Set Report Server web service URL and credentials
2. Read
.rdl file as a byte array. [Here I assume that datasource and dataset
information are part of .rdl file as XML. If this is not the case with you then
you may need to create datasource and dataset either programmatically in
following code or you can create from designer. Then attach to the deployed .rdl
file].
3. Then
I create a folder on report server. You should add code to check if it exists
already otherwise it will throw an error.
4.
Then create catalog item to deploy report .rdl file using following code -
public void DeployReportToReportServer(string rdlFilePath)
{
ReportingService2010 rs = new ReportingService2010();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url ="http://ServerNameHavingSQL2012:PortNumber/reportserver/reportservice2010.asmx";
//read
rdl file
FileStream _stream = File.OpenRead(rdlFilePath);
byte[] _reportDefinition = new Byte[_stream.Length];
_stream.Read(_reportDefinition, 0,
(int)_stream.Length);
_stream.Close();
//Create
Folder to drop report in - should have existence code****
rs.CreateFolder("MSI Report Demo", "/", null);
Warning[] warnings = null;
CatalogItem c = rs.CreateCatalogItem("Report", "Report1.rdl", "/MSI Report
Demo", true, _reportDefinition, null, out warnings);
}
Hope
this helps. Cheers…
Happy
Deploying!!!
Where is the code for the deployment? There is link in the page.
ReplyDeleteMethod DeployReportToReportServer contains the code to deploy rdl file to ssrs.
DeleteBest solution yet
ReplyDeleteThere is no class in the WSDL "http://localhost/reportserver/reportservice2010.asmx" named ReportingService2010
ReplyDeleteThe code, ReportingService2010 rs = new ReportingService2010(); is not resolving to anything.