byte[] report = null;
//create an instance of the reporting service web reference
var reportReference = new ReportExecutionService();
<strong>//Set your proxy settings
reportReference.Proxy = new WebProxy("address:port");
//create a credential that will be used to authenticate again the
reporting services
var credential = new NetworkCredential("username",
"password", "domainName");
reportReference.Credentials =
credential;
reportReference.PreAuthenticate =
true;
//the virtual path to the report
string virtualPath = "/Folder/ReportName";
//Specify the device info
string deviceInfo =
"<DeviceInfo><Toolbar>False</Toolbar><Parameters>False</Parameters><DocMap>True</DocMap><Zoom>100</Zoom></DeviceInfo>";
//Create an array of parameters, for example our report needs 2 parameters
var parameters = new ParameterValue[2];
//Specify the value for the parameter
var startDateParameter = new ParameterValue();
startDateParameter.Name = "StartDate";
startDateParameter.Value = "01/01/2008";
parameters[0] = startDateParameter;
var endDateParameter = new ParameterValue();
endDateParameter.Name = "EndDate";
endDateParameter.Value = "31/12/2008";
parameters[1] = endDateParameter;
//Create variables for the remainder of the parameters
string extension = string.Empty;
ExecutionHeader executionHeader = null;
reportReference.ExecutionHeaderValue =
executionHeader;
reportReference.LoadReport(virtualPath,
null);
reportReference.SetExecutionParameters(parameters,
"en-AU");
try
{
//Execute the report
string[] streamIDs;
Warning[] warning = null;
string encoding;
string mimeType;
string format = "PDF";
<strong>//Execute the report
report = reportReference.Render(format,
deviceInfo, out extension, out
mimeType, out encoding,
out warning, out streamIDs);
using (var fileStream = new FileStream("myReport.PDF", FileMode.Create))
{
fileStream.Write(report, 0,
report.Length);
fileStream.Close();
}
> Process.Start("myReport.pdf");
}
catch (SoapException exception)
{
}