|
Understanding Reporting Services Web Service Access
|
|
In the last article titled,
Accessing Reports via URLs and Embedding Reports, we saw the URL method
of accessing reports. This method of access is suitable for ad-hoc access,
given that you know the report server URL, the report that you want to access
and the parameters that the report requires. It is also useful for embedding it
inside applications to quickly get at the report. But what if you want more
control?? Say for example you want to change the data source of the report at
runtime or you want to create a new schedule for the report?? This type of
control is not provided by the URL method. Fortunately, the report server also
presents a full-fledged web service that allows you to do anything with the
report server that the report manager can. Remember that the report manager is
the .NET web based application that you can use to manage and maintain your
reports. All that you can do with the report manager application, you can do
using the reporting services web-service.
In this article we will see how to access the report server using the web-service and then see an example of how to use the web-service in a normal application. I will assume that you are already familiar with using SQL Reporting Services. If you are not, please read the following articles (in the same order): I will also assume that you have some experience programming with web services. So let's get cracking! The first step in programming against the web service is to make a reference to it. Before we the steps to do that, let us see how you can get at the WSDL for the reporting web service. You can find the web-service WSDL at the following location:
You can type this URL in your browser and observe the WSDL that is generated. Note that in the example above, the report server is running locally on my machine. The name of the web-service is called reportservice.asmx. If you can see the WSDL, then everything is fine and we can now proceed to build the sample. The application that we will build here is a simple Windows Forms application. Open Visual Studio .NET and create an empty Windows Forms application. Then, add a reference to the reporting service web-service by using the URL shown above. The following figure shows the web-reference dialog box, with the reporting web-service referenced.
Note that we have given the web-reference a name of ReportWS. This name will be used in the program to reference the web service. Now that we have a reference to the web service, design a form as shown in the following figure.
The user interface is very simple. We have a button called Get All Items, which we will use to get all the items defined in the report server and a list box called lstFolders that will contain all the items. Let us now write the code for populating the list box with content. The following snippet illustrates the code to be written.
I've shown two code pieces:
Let us now run this program. When you run the program, you get the window designed above and when you click the button, you get the list of all items defined in the report server. Note that the display may differ based on what you have created in your report server. The following figure shows the output from my machine.
That's pretty cool eh! You can see all the items that are present in the report server and an explanation about the type of the resource. You can also print other properties of the resource if you need. But wait, do you feel that something is wrong in the display?? To check this out, see the following figure:
The above figure shows the contents of my root folder and we see that there are two items My Experiments and TimeSheet. Under each of these folders, I have other items (and possibly other folders too). But, in our display from the application, we saw all items listed in a single order with no apparent formatting done for the folder structure. For example, the New Folder folder in the figure above is actually under the My Experiments folder and Test Data Source is inside that folder. Our display however did not take care of this relationship, but it is easy to build such a structure and I leave it as an exercise for the reader to try it out. Well, that brings us to the end of this quick introduction
to the reporting services web-service. There are many other variations of this
sample that you can build and in future articles we will explore some esoteric
usage of the web-service. For now, in this article we had a quick look at the
power that you have when you use the reporting service web service. Have fun!!
|
| Home |