Compiling and Running Code Examples
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
The code examples in the Report Server Web service library documentation are simple applications that perform Report Server Web service operations using many of the Web service methods that are available to you. These applications write the output to the console or command prompt.
Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator. Microsoft does not provide technical support for these samples.
The SQL Server samples are not installed automatically during setup. For instructions about how to install the samples, see Considerations for Installing SQL Server Samples and Sample Databases.
Using the Microsoft .NET Framework SDK
You can use several tools in the .NET Framework SDK to compile and run Reporting Services code examples. You can obtain the .NET Framework SDK free of charge. For more information, see Installing the .NET Framework Documentation.
To compile and run a code example
Create a Reporting Services proxy class in either Microsoft Visual Basic or Microsoft Visual C++ using the WSDL tool. For more information about using this tool, see Creating the Web Service Proxy.
Compile the proxy class source code file into a .NET Framework assembly using the following commands:
For Visual Basic, use Vbc.exe to compile the proxy class and produce a DLL. For example:
vbc /target:library ReportingService2005.vb /r:System.dll /r:System.Xml.dll /r:System.Web.Services.dll
For C#, use Csc.exe to compile the proxy class and produce a DLL. For example:
csc /target:library ReportingService2005.cs /r:System.dll /r:System.Xml.dll /r:System.Web.Services.dll
Using a text editor, create a blank text file named sample with either a .vb extension (for Visual Basic sample code) or a .cs extension (for C# sample code).
Copy and paste the code example you want to run into the blank file. Save the file.
Open a command prompt: From the Start menu, click Run, type cmd in the text box*,* and then click OK.
At the command prompt, type one of the following commands to compile the sample. The paths to your sample file and to the RSWebService.dll might differ from those provided in the following samples.
For Visual Basic, use Vbc.exe and use the following command to reference the proxy class and the system libraries needed to run the application:
vbc sample.vb /r:ReportingService2005.dll /r:System.dll /r:System.Web.Services.dll /r:System.Xml.dll
For C#, use Csc.exe and use the following command to reference the proxy class and system libraries needed to run the application:
csc sample.cs /r:ReportingService2005.dll /r:System.dll /r:System.Web.Services.dll /r:System.Xml.dll
The compiler creates an executable called Sample.exe. To run the compile sample, type sample.exe at the command prompt.
Using Visual Studio
You can use the Visual Studio development environment to build and run Reporting Services code examples.
To compile and run a code example
On the File menu, click New Project.
In the New Project dialog box, in Project Types, click Visual Basic Projects or Visual C# Projects.
In the right pane, click Console Application.
In the Name box, type a name for the new project.
In the Location box, select the location you want to save the file to.
Add a Web reference to your application. For more information about adding a Web reference to the Report Server Web service in Visual Studio .NET, see Creating the Web Service Proxy.
Rename the Class1.cs project file to Sample.cs. For Visual Basic, rename Module1.vb to Sample.vb.
Copy and paste the code example you want to use into the space provided in the sample code file. Save the file.
Start the application: Press F5, or click Start on the Debug menu.
Using the rs Utility
Reporting Services provides a scripting utility, the rs utility, which is shipped as a file named rs.exe. You can run any Visual Basic code example that is provided in the Report Server Web service library documentation using the rs utility that is included with Reporting Services.
To run a code example
Using a text editor, create a blank text file named sample with an .rss extension.
Copy and paste the following code into the blank file:
Public Sub Main() ' Your code goes here. End Sub
Copy and paste the code example you want to use into the space provided in the previous code sample. Save the file. If you are copying directly from a code example provided in a reference topic, remove any import statements, module declarations and the following line of code:
Dim rs As New ReportingService2005()
The ReportingService2005 object is already declared and instantiated within the script environment. Redeclaring the object in your code will cause your script to fail. For more information about properly formed scripts, see Formatting the Reporting Services Script File.
Open a command prompt: On the Start menu, click Run, type cmd in the text box, and then click OK.
Navigate to the directory that contains your Sample.rss file. At the command prompt, type the following command to run the sample script file. Be sure to replace the given server URL with that of the report server and endpoint you are accessing. For example:
rs –i sample.rss –s http://myserver/reportserver
If you receive a message that rs is not recognized, you may need to add the location of rs.exe to your Windows environment variable PATH.