Windows Azure SQL Reporting: using SOAP APIs

Device information settings in SSRS are used to pass parameters to a rendering extension. For more information regarding device information settings in reporting services, see Passing Device Information Settings to Rendering Extensions.

For SQL Reporting, none of the options specified in the above article are feasible. We see a lot of scenarios where we would want to modify these settings, and render/export the report in the format that we are looking for.

For SQL Reporting reports, we can explore the SOAP APIs in modifying these device information settings at the run time. If we have integrated SQL Reporting within our applications, this approach is really easy, by just creating a separate function.

Here are some steps to achieve this:

  1. Generate the proxy class for ReportExecution2005.asmx.
  2. Now you have the file named: ReportExecutionService.cs. Add the file to your Windows Azure Project. You can use a function similar to the one provided below: 
    public void Render_Export()
                ReportExecutionService rs = new ReportExecutionService();
                rs.Url = String.Format("https://{0}:443/ReportServer/reportExecution2005.asmx", ConfigurationManager.AppSettings["SERVER_NAME"]);
                rs.CookieContainer = new CookieContainer();
                rs.LogonUser(ConfigurationManager.AppSettings["USERNAME"], ConfigurationManager.AppSettings["PASSWORD"], ConfigurationManager.AppSettings["SERVER_NAME"]);
                byte[] result = null;
                string reportPath = "/SSRSReport/Report5";
                string format = "CSV";
                string historyID = null;
                // Setting the deviceinfo parameters
                string devInfo = @"<DeviceInfo><FieldDelimiter>;</FieldDelimiter></DeviceInfo>";
                string encoding;
                string mimeType;
                string extension;
                Warning[] warnings = null;
                string[] streamIDs = null;
                ExecutionInfo execInfo = new ExecutionInfo();
                ExecutionHeader execHeader = new ExecutionHeader();
                rs.ExecutionHeaderValue = execHeader;
                execInfo = rs.LoadReport(reportPath, historyID);
                String SessionId = rs.ExecutionHeaderValue.ExecutionID;
                // code snippet to set the DataSource credentials.
                if (execInfo.CredentialsRequired)
                    List<DataSourceCredentials> credentials = new List<DataSourceCredentials>();
                    foreach (DataSourcePrompt dsp in execInfo.DataSourcePrompts)
                        DataSourceCredentials cred = new DataSourceCredentials();
                        cred.DataSourceName = dsp.Name;
                        cred.UserName = ConfigurationManager.AppSettings["USERNAME"];
                        cred.Password = ConfigurationManager.AppSettings["PASSWORD"];
                    Console.WriteLine("Setting data source credentials...");
                    execInfo = rs.SetExecutionCredentials(credentials.ToArray());
                // Code snippet to render the file to a specified format.
                    result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
                    execInfo = rs.GetExecutionInfo();
                catch (Exception ex)
                    throw ex;
                // Code snippet to write the file to a specific location using FileStream object
                    FileStream stream = File.Create(@"D:\report.csv", result.Length);                
                    Console.WriteLine("File created.");
                    stream.Write(result, 0, result.Length);
                    Console.WriteLine("Result written to the file.");
                catch (Exception ex)
  3. You can use a config file to store the Username, Password and SQL Reporting server name. The config file will have information as specified below:
      <add key="SERVER_NAME" value=""/>
      <add key="USERNAME" value="UserName"/>
      <add key="PASSWORD" value="Password"/>    
  4. Modify the values as per your SQL Reporting server details.
  5. You might need to extend the default Reporting Services proxy class to enable cookie management, because SQL Reporting uses forms authentication.

For more information about unsupported APIs in SQL Reporting, see

Other references:


    Any questions around this, feel free to ping me.



    Comments (6)
    1. Dmitriy Skibin says:


      I'm integrating Azure reporting features in my web app (ASP.NET MVC 3) and get the problem.

      During the report rendering  (by calling rs.Render method) i always get exception "Unexpected end of file has occurred. The following elements are not closed: Result, RenderResponse, soap:Body, soap:Envelope. Line 1, position 7401792." It seems that soap message truncated. This problem only for reports with large resulting document (.pdf). For reports with small resulting document all works fine. Do you know about soap message size limitations on Azure reporting service? On my local SSRS large reports are works fine. Thank you in advance!

    2. I am not aware of this.. I will check and get back to you.. What is the size of the report that you test this out?

    3. Hi.

      I run the report with the resulting .pdf document of 5.9 mb. And it fires exception. If i choosed xml result type the report rendered successfully. Resulting  size of the xml file – 3.9 mb.

    4. Hi, Chaitanya.

      Do you have any updates for me?

    5. Hi Dmitriy, can you send me an email by clicking on "Email Blog Author", we will take this offline and work with you.



    6. @Dmitriy: I tried with a report which generates 7.1MB size of PDF, but didnt run into issues. What is the error that you see? Is this issue reproducible or happens everytime you run the report?

    Comments are closed.

    Skip to main content