Here is a code sample that I use to show developers at my clients how to pull a report.
string historyID = null;
string deviceInfo = null;
string format = "Excel"; //Can be XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, and HTMLOWC
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
ReportingExec.Warning warnings = null;
string streamIDs = null;
ReportExecutionService re = new ReportExecutionService();
re.Credentials = System.Net.CredentialCache.DefaultCredentials;
ExecutionInfo ei = re.LoadReport("/directory/ReportName”, historyID);
ReportingExec.ParameterValue rptParameters = new ReportingExec.ParameterValue;
rptParameters = new ReportingExec.ParameterValue();
rptParameters.Name = "DateFormatID";
rptParameters.Value = "fr-FR";
results = re.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
FileStream stream = File.Create("C:\\report.xls", results.Length);
stream.Write(results, 0, results.Length);
You will need to set up the reference in your project. The URL for this is: http://servername/reportserver/ReportService2005.asmx
This code, which I give to the developers in a web app, demonstrates the basic use of the web services. It loads a report, adds a parameter value, and then renders the report and saves it to disk. If you wanted to render it back to the user on a web page, you would add:
Response.AddHeader("content-disposition", "attachment; filename=File.xls");
Response.OutputStream.Write(results, 0, results.Length);
By taking this code a little further, you could easily send out an email with the report attached. Or another commonly requested feature for SSRS: emailing multiple reports on 1 email.
You could loop thru a database table, reading the reports to send a user, render that report, save the file, attach it to a system.mail email, and then move to the next report. When the looping for that user is complete, send the email, delete the files, and move on to the next user in the table.
I hope this helps clear up web services in SSRS 2005. Most developers that I work with are not familiar with this web service, and this always gets them going in the right direction. This is by far a VERY basic demonstration. There is a lot more to the web services than just this.
For more reading on the web services, visit: