Home > Articles > Data > SQL Server

  • Print
  • + Share This
This chapter is from the book

The Report Server

After you've used the Report Designer to design and build a report definition or report project (which might contain any number of report definitions, shared Data Sources, and resources such as graphic files), you deploy it by sending its RDL (or RDS if a shared Data Source, or the resource file if a graphic) to the ASP.NET-based Report Server. Before attempting to deploy a report, it's crucial to configure two properties on each report project in Visual Studio .NET 2003: the target URL of the Report Server, and the notional folder to which you wish to deploy. You'll also want to reference an appropriate StartItem report, as shown in Figure 1.15.

01fig15.jpgFigure 1.15 The Project Properties Page—Ready for Deployment

To deploy a project or a single report within a project, right-click the project or report name and choose Deploy. Once a report definition is complete and deployed to the Report Server, it becomes a managed report.

The Report Server exposes Reporting Services' SOAP endpoint, and Visual Studio .NET deploys the report and shared Data Sources and resource files by simply making calls to SOAP methods. All these report definitions, shared Data Sources, and resource files are organized in the Report Server in a logical folder hierarchy, over which is an extensive role-based security system integrated with Computer/Domain Users and Groups.

I say "XML-like" because although some of these files look like XML, if you try to put in XML comments—for example, <!--A Comment-->— this can choke SQL Server, and the exception messages can be pretty cryptic. We'll discuss these configuration files later in this chapter.

Peter

If you're developing your own tools or being paid by the hour and you want to build your own .NET application to deploy reports, you can call the SOAP interface from your own programs. We'll show you how in Chapter 9¾.

The Report Server uses a SQL Server 2000 database to retain almost all of its metadata. In fact, the only modifiable metadata retained outside SQL Server are any custom assemblies and supporting files you may have written that the report references, along with a handful of XML-like configuration files for the web and Windows services and security policies.

SQL Server and SOAP

Although Reporting Services uses SQL Server as its own data store and you can get at the Reporting Services' own tables and stored procedures, we should warn you that the only officially supported interface is SOAP. The reason is that as the product progresses, Microsoft might (is likely to) change/tune/alter/repair/enhance/refine the underlying schema of the Reporting Services database and the definitions of the stored procedures. Microsoft has confirmed that the SOAP interfaces will be backwardly supported but says that the use of SQL Server by Reporting Services for its data store is a (publicly undocumented) implementation detail subject to change. So if you feel inclined to fiddle directly within the Reporting Services ReportServer database with T-SQL, be warned that a next version or Service Pack could (and probably will) break your code. This is a little frustrating because calling out to a SOAP interface from T-SQL in SQL Server 2000 is not as trivial as it will be in the next version of SQL Server (SQL Server 2005).

Rendering Extensions

In addition to SOAP-type HTTP and HTTPS calls, the Report Server's ASP.NET web server component dutifully responds to specially formatted URL Request Strings by streaming requested reports over HTTP or HTTPS in an amazing number of rendering formats. The rendering formats that a Report Server can generate are governed by the Rendering extension assemblies installed and registered on the system. Out of the box there are six Rendering extensions: HTML (3.2, 4.0, MHTML), XML, CSV, IMAGE (BMP, EMF, GIF, JPEG, PNG, TIFF), EXCEL, and PDF.[14]

Stop and think for a moment about where we are. At this point, we have the ability to design and render a report in a variety of formats, which can target a number of potential platforms and devices. We should also emphasize that there is no additional separate license fee to pay to Adobe for the PDF report generation, and there is a way to extract an HTML table fragment stream, which you can incorporate directly into one of your own web pages without having to use an IFrame control. [15]

But as if that were not enough, in true TV shopping style—"Wait! There's more!"—you also get the ability to create and register any of your own custom Rendering extensions. So, for example, if you have a commercial requirement that your reports be rendered on Wireless Application Protocol (WAP)-enabled phones, you can write a .NET Rendering extension assembly for Reporting Services to do so. But be warned—developing Rendering extensions is hard, at least in our opinion. Configuring the Report Server to use a new Rendering extension is as simple as placing your custom rendering assembly in the right folder and delicately editing a few XML configuration files. We suggest you investigate the existing Rendering extensions, such as using Extensible Stylesheet Language Transformations (XSLT) with an XML-rendered report. This might satisfy your requirements without the need to write a new extension.

Does anyone still have a WAP phone? Do yourself a favor and get a Smartphone or PocketPC phone. I was one of the first to use WAP technology and blew a load of dough writing WML servers and translators. Thanks, Nokia, for nothing!

Peter

Delivery Extensions

So far we've talked about being able to extract a rendered report stream in response to a specially formatted URL, but the Report Server need not always be shy and passive. Reporting Services does have the ability to break out of its box and start spamming preconfigured and presumably consenting recipients over SMTP [16] at preset scheduled times or only when the data changes.

And if benevolent spam is not enough, the Report Server can even proactively save rendered reports onto a UNC [17] file share on a certain schedule or when data changes. Yes, it even takes care of any credentials it might need to use to access that share, and it can set access credentials on the saved file to restrict access to a certain computer or domain user or group. It can also be configured to overwrite any previous file or to incrementally number files so as not to overwrite any previous file.

Both delivery features are provided through what are called Delivery extensions, and yes, you can write your own .NET Delivery extension assembly to proactively deliver reports elsewhere. For example, you can send to an FTP [18] service, post it using NNTP [19] to a newsgroup, or dispatch an SMS message to a WAP-enabled phone, with the embedded link pointing to where you use your WAP Rendering extension. The extensible delivery possibilities are endless, and they are, for the most part, much easier to develop than Rendering extension assemblies.

What About Printing Delivery Extensions?

We have, however, discovered a small fly in the ointment. In the initial release version there isn't an out-of-the-box Delivery extension to send reports directly to a printer. Thankfully, the Microsoft development team has not left us completely high and dry; they provide project code samples in C# and Visual Basic .NET that show how to make a Delivery extension that targets a printer.

If you stop to think for a moment about how many printers there are in the world and how many different printer drivers there are to take advantage of the plethora of hardware-specific configurable options—such as duplex printing, paper size selection, input and output trays, color printing, margin settings, collation, stapling, binding, faxing, scaling, even the number of copies that should be printed—it would have been a mammoth undertaking for the development team to have created a generic printer Delivery extension that would cater to every possible option, and time constraints pushed this part of the development out to the next version. Our guess is that printer manufacturers and third-party ISVs [20] will write their own printer Delivery extensions that take advantage of their hardware's features to make them fully available to Reporting Services. The Delivery extension sample provided by the Reporting Services developers works by rendering the report as an image and sending that to the printer. This is certainly not the most efficient way to solve the problem—being more "crude but effective," as Seven of Nine might say. [21] All of this said, we are working on a server-side printing extension that can be called directly from the Report Manager when viewing a report, so be sure to check our website www.SQLReportingServices.NET for news.

The SQL Server Agent and ReportingServicesService.exe Windows Service

The Report Server is not alone when it comes to its ability to push report content through Delivery extensions. It's aided and abetted by two friends: the SQL Server Agent and another Windows system service that you'll see in your task manager as the tautological ReportingServicesService.exe, which is a .NET Windows system service. These provide an infrastructure that enables possible load balancing in a web farm environment when you're pushing scheduled content out via Delivery extensions. (For more on web farms, see Chapter 2.)

While the SQL Server Agent creates entries in the ReportServer database's Event table at scheduled times, it's the ReportingServicesService.exe Windows system service that polls the database every 10 seconds to see if there are any entries in this table and takes appropriate action. Chapter 2 tells you how you can configure the polling interval.

The Report Processor

The Report Processor is the thoroughbred workhorse [22] of the Reporting Services team (see Figure 1.16). It's only used to process managed (deployed) reports. It's responsible for querying data, assembling the report into the Intermediate Format (IF) Binary Large Object (BLOB), and extruding the report to the client. This is where the various extensions come into play. For example, a Data Processing extension is used during report processing to query the report's Data Sources. Data and layout are combined by the Report Processor and saved to the database in the IF. Only at this stage does the Rendering extension come into play. The benefit of this approach is that all the querying and processing work is done once, after which different renderers can be called—all of which can work from the same IF BLOB. This Intermediate Format can be persisted behind the scenes in the ReportServer database to enable reports to be rendered from cached versions, historic versions, or Snapshots. The fundamental difference between immediate in-demand, cached Snapshots and history is simply where and how long a generated report is stored and managed. (You'll learn more about report history and Snapshots shortly.) The key to the Intermediate Format is that all the heavy lifting is done once, and that it's device (renderer) independent.

01fig16.jpgFigure 1.16 The Report Processor

Caching Intermediate Format

To obtain some performance gains and scalability, the Report Server can cache the generated report IF in a SQL table within the Report Server database—assuming that the credentials used in the report's Data Sources are not derived from Windows Authentication security (SSPI) or by prompting the user. If caching is enabled on a managed report, the report can be delivered much more quickly after it has been requested the first time because the Report Server doesn't have to query all the Data Sources again; it need only render the IF into the requested stream type. Reports can be cached for a configurable number of integer minutes to a maximum of 2,147,483,647—approximately 4,083 years, by which stage we doubt you'll still be bothered (assuming your system stays up that long). For a higher degree of control, the cache can be expired on a report-specific schedule or on a schedule shared with other objects.

For parameterized cache-enabled reports, the Report Server creates IF images and caches the report each time it's requested by means of parameter values that have not already been used, compiled, and cached. In other words, the cache is uniquely indexed on a report and on the parameter values with which it was executed. Reports remain in the cache until they expire or are explicitly flushed from the cache.

Caching Snapshots

The first time a report is executed, it can take a very long time, especially if a lot of number crunching is required in the report's queries or if you asked for all 50,000 customers. Microsoft has provided an alternative to deal with this contingency: the ability to populate the cache with an Intermediate Format Snapshot from a report executed at a scheduled time. Again, the schedule can be specific to a report or can be shared with other objects and must use hard-coded credentials. This approach is designed to support preparation of reports in off-peak hours.

Caching History

The Report Server can maintain a historic archive of Intermediate Format report Snapshots that can be repeatedly rendered at any time in the future—assuming that the system is still up when it's time to render the report. This history can be unlimited—or, more accurately, limited—by what SQL Server can provide in storage space. The Report Server can generate Snapshot reports on shared schedules or on a report-specific schedule.

The Report Execution Timeout Governor

Preparing the Intermediate Format for reports can take considerable time, especially if there is a lot of data to collect or if complex processing is required. Fortunately, the Report Server provides the option to time out the execution of a report and cancels it with a polite [23] message to the user. This Report Execution Timeout setting is set in seconds, and there is a default for the whole Report Server; this default can be overridden on a report-by-report basis.

The default timeout is close to 60 seconds. The Report Server evaluates running jobs at 60-second intervals. Every 60 seconds, the server compares actual process time against the report execution timeout value. If the processing time for a report exceeds the report execution timeout value, report processing stops. If you specify a timeout value that is less than 60 seconds, the report may execute in full if processing starts and ends during the quiet part of the cycle when the Report Server is not evaluating running jobs. For example, if you set a timeout value of 10 seconds for a report that takes 20 seconds to run, the report will process in full if report execution starts early in the 60-second cycle. You can set the RunningRequestsDbCycle setting in the RSReportServer.config file to change how often running jobs are evaluated.

  • + Share This
  • 🔖 Save To Your Account