Exception thrown by the ReportingService webservice
Hi,
Hopefully, this is the correct forum to post this problem. It's about web services, but it's also about Reporting Services.
I'm trying to render a Reporting Services report using .NET. In order to do this, I first publish the report's RDL file to the Reporting Services running on localhost, and then call the Render()-method of the ReportingService.cs instance. This works if the database which the report is evaluating contains little data. If it contains large amounts of data, it gives me an a WebException. It's not clear what the problem is: I used to get a timeout exception, but I changed the timeout. The new Exception I'm getting is less clear about what exactly doesn't work. It simply says "Die zugrundeliegende Verbindung wurde geschlossen: Beim Empfangen ist ein unbekannter Fehler aufgetreten..". I assume this translates to "The underlying connection was closed: An unexpected error occurred on a receive."
The ReportingService class itself inherits from SoapHttpClientProtocol. The Exception occurs inside this class, namely when the instance tries to call
this.Invoke(...)
Here's Microsofts documentation for the ReportingService class:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_ref_soapapi_service_ak_1xfd.asp
Basically, it boils down to this:
1) I'm wondering if there's a way to render an RDL file without having to publish it to the web service and then render it?
2) If not, what could I try to fix the problem? As I said, it only occurs with large amounts of data, i.e. when it takes ReportingService a long time to render the report, so I assume it's some kind of timeout or "out of memory" issue.
Here's the exception that's being thrown:
An unhandled exception of type 'System.Net.WebException' occurred in system.web.services.dll
Additional information: Die zugrundeliegende Verbindung wurde geschlossen: Beim Empfangen ist ein
unbekannter Fehler aufgetreten..
And here's my code which causes the Exception to be thrown (the line containing the method call "results = reporting_service.Render(...) throws the exception):
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.IO;
using System.Web.Services.Protocols;
namespace DBInvestigator
{
public class ReportRenderer
{
private ThreadWindow threadwindow;
private Coordinator my_coordinator;
private string host,login,password,database,format;
private bool writereport;
private string rdlfilename,reportname;
public ReportRenderer(ThreadWindow threadwindow, Coordinator my_coordinator)
{
this.threadwindow = threadwindow;
this.my_coordinator = my_coordinator;
}
public void SetParameters(string host,string login,string password,string database,string format,bool writereport, string rdlfilename, string reportname)
{
this.host = host;
this.login = login;
this.password = password;
this.database = database;
this.writereport = writereport;
this.rdlfilename = rdlfilename;
this.reportname = reportname;
this.format = format;
}
public void WriteReport()
{
// create an instance of ReportingService
ReportingService reporting_service = new ReportingService();
reporting_service.Timeout = int.MaxValue;
reporting_service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// read the rdl file
Byte[] definition = null;
try
{
FileStream stream = File.OpenRead(this.rdlfilename);
definition = new Byte[stream.Length];
stream.Read(definition,0,(int)stream.Length);
stream.Close();
}
catch (IOException ioexc)
{
ErrorReporter.Exception(this,ioexc);
}
// publish the rdl file
reporting_service.CreateReport(
"Report1",
"/TempReports",
true,
definition,
null);
// render the published report
ReportParameter[] parameters = reporting_service.GetReportParameters(
"/TempReports/Report1",
null,false,null,null);
string encoding;
string mimetype;
ParameterValue[] history_params = null;
string[] stream_ids = null;
Warning[] warnings2 = null;
DataSourceCredentials[] credentials = new DataSourceCredentials[1];
credentials[0] = new DataSourceCredentials();
credentials[0].Password = this.password;
credentials[0].UserName = this.login;
credentials[0].DataSourceName = this.database;
Byte[] results;
// the next line throws the exception
results = reporting_service.Render(
"/TempReports/Report1",
this.format,
null,
null,
null,
credentials,
null,
out encoding,
out mimetype,
out history_params,
out warnings2,
out stream_ids);
// write the rendered report to a file
FileStream stream2 = File.OpenWrite(this.reportname);
stream2.Write(results, 0, results.Length);
stream2.Close();
}
}
}