Automated deployment of .rdl files to SQL Server 2012 Reporting Services using c# and Reporting web Service of SSRS 2012

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 illus07ates 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 s07ing parameter. This s07ing 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.
Steps are as follows –

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(s07ing rdlFilePath)
        {
            ReportingService2010 rs = new ReportingService2010();
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            rs.Url ="http://ServerNameHavingSQL2012:PortNumber/reportserver/reportservice2010.asmx";

        

 

            //read rdl file  

            FileS07eam _s07eam = File.OpenRead(rdlFilePath);

            byte[] _reportDefinition = new Byte[_s07eam.Length];

            _s07eam.Read(_reportDefinition, 0, (int)_s07eam.Length);

            _s07eam.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", 07ue, _reportDefinition, null, out warnings);

        }

 

Hope this helps. Cheers…

Happy Deploying!!!

Comments

Popular posts from this blog

The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used

Getting Started with Logic Apps - AS2

How to Debug and Trace request in Azure APIM - Portal, Postman, RequestBin