Welcome!

Microsoft Cloud Authors: Pat Romanski, Andreas Grabner, Nick Basinger, Kevin Benedict, Liz McMillan

Related Topics: Microsoft Cloud

Microsoft Cloud: Article

INETA's Topic Choice: Programming SQL Reporting Services

Extend SQL Reporting Services reports through Web services and .NET assemblies

SQL Server Reporting Services is a comprehensive, server-based solution that enables the creation, management, and delivery of both traditional, paper-oriented reports and interactive, Web-based reports. An integrated part of the Microsoft business intelligence framework, Reporting Services combines the data management capabilities of SQL Server with familiar and powerful Microsoft Office System applications to deliver real-time information to support daily operations and drive decisions.

Reporting Services provides an embeddable and extensible framework that enables customers and partners to build custom business intelligence applications. Developers can use any developer tool or platform that works with Web services. This flexibility and interoperability makes it easier to create reports that leverage packaged or custom applications in almost any environment.

While Reporting Services provides a complete set of built-in reporting functionality, its modular architecture is designed for extensibility. Server extensions are pieces of managed code that execute inside the Report Server. Reporting Services supports four types of custom extensions: output rendering, security frameworks, delivery options, and data processing types. At a more granular level, it is also possible to write custom .NET assemblies or embed custom code in a report that can be used by report expressions for custom formatting and calculated fields.

Using SQL Reporting Web Services
The Reporting Services Web service is an XML Web service with a Simple Object Access Protocol (SOAP) API. You can use the Web service to add the full functionality of Reporting Services to your business applications. The Web service interface provides a set of rendering and viewing functions. However, the Web service also provides additional functionality for managing the contents of a Report Server through an extensive set of more than 75 Web methods.

For scenarios in which the management of reports, subscriptions, schedules, data sources, and other Report Server items is a requirement, the Web service provides a single entry point to the full report-management functionality of the Report Server. It is easy to develop applications that leverage the Web service using Microsoft Visual Studio .NET or any other SOAP-enabled development tools.

To call a Web service successfully, you must know how to access the service, what operations the service supports, what parameters the service expects, and what the service returns. WSDL provides this information in an XML document that can be read or processed by a computer. WSDL can be consumed by development kits that support SOAP and Web services, such as the Microsoft .NET Framework SDK.

To access Reporting Services' WSDL file using Visual Studio .NET, use the following URL: http://server/reportserver/ReportService.asmx (where server and reportserver are the names that were used when Reporting Services was installed). Once the location of the Web service WSDL is known, just three simple steps are required to make a Web service call.

  1. Create a proxy class that references the WSDL file location using WSDL.exe, or create a Web reference to the URL.
  2. Authenticate the client with the report server using the credentials of an authenticated user.
  3. Call the Reporting Service method you want to invoke.
See Listing 1 for an example of how to retrieve all of the reports in a particular folder on the reporting server.

Another very powerful feature of the available Web services is the ability to render a report directly to a byte array in whatever format a user chooses. This byte array can either be saved directly to a file or sent to a browser for immediate viewing. The render function is very flexible in that it allows for the passing of a parameter array that the report can use to filter the data. See Listing 2 for an example that shows how to render a parameterized report directly to PDF format and open it in Adobe Acrobat viewer.

Using Custom .NET Assemblies and Embedded Code in Report Expressions
Custom code can be written that is used in expressions throughout a report. This can be done in two ways: embedding code within a report or by referring to methods within a custom assembly. It is acceptable to use "embedded" code for complex functions or functions that are used multiple times in a single report. However, if the code will be shared across multiple reports, then a .NET assembly that is stored on the server is more appropriate.

To embed code within a report, navigate to menu Report > Report Properties and select the code tab. If you do not have a report menu showing, just click somewhere on the report in the designer and it will appear. This custom code can contain multiple methods, which must be written in Visual Basic .NET and must be instance based. Methods in embedded code are available through a globally defined code member. The functions can be accessed by referring to the code member and method name. The example shown in Figure 1 calls the method SetColorToRed, which sets the color of a textbox font to red if the value is greater than a certain limit:

=Code.SetColorToRed (Fields!StandardCost.Value, 800)

To use custom .NET assembly functions in a report, the assembly must be referenced in the report properties window on the References tab (see Figure 2). Note: For issues related to deploying, securing, and debugging custom assemblies, please see the resources section.

To refer to custom functions in an expression, a direct call to the member of a class within the assembly must be made. This can be done by either calling static or instance-based methods. Static methods within a custom assembly are available globally within the report and can be called from expressions by namespace, class, and method name. The following example refers to the method SetColorToRed in the TechArch assembly:

= TechArch.CustomFormatting.SetColorToRed (Fields!StandardCost.Value, 800)

Instance-based methods are available through a globally defined code member. These methods can be accessed by referring to the code member, and then the instance and method name. The following example calls the instance method SetColorToRed:

=Code.m_myCustomFormatting.SetColorToRed (Fields!StandardCost.Value, 800)

Custom Extensions for SQL Reporting Services
The unique extensibility architecture of Reporting Services allows for enhancements to specific features of the product and its components. For instance, data processing extensions are responsible for returning a result set based on connection information, a query, and optional parameter values. These data extensions are able to connect to legacy or custom data sources. A data extension implements a subset of the .NET Managed Data Provider interfaces. This type of extension can optionally implement a set of extended interfaces to provide additional design-time information. In addition, there are delivery, rendering, and security extensions that allow for customized report outputs, formats, devices, and security frameworks.

Deploying an extension is as straightforward as copying a .NET assembly to the Report Server and adding a line of code to the sever configuration file. The Report Server automatically detects the new extension and makes it available to users. For in-depth information on extensions, please see the Resources section.

SQL Reporting Services is a very flexible, enterprise reporting framework that provides a rich set of features out of the box. By exposing all of the service's functions through XML Web services and allowing access to custom .NET assemblies, Microsoft has opened the door for its users to implement Reporting Services in a variety of scenarios. Because of this flexibility, SQL Reporting Services can be used as a stand-alone report distribution platform, be easily integrated into corporate portals, or be called from WinForms/Web applications. Even though SQL Reporting Services is in its first release, it is a stable and scalable solution for any size company.

Resources

  • SQL Server 2000 Reporting Services: www.microsoft.com/sql/reporting
  • Reporting Services Web Service Library: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_ref_soapapi_8cxl.asp
  • Reporting Services – Building Applications Using the Web Service and the .NET Framework: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_prog_soapapi_dev_3g0y.asp
  • SQL Server 2000 Reporting Services Books Online: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPORTAL/HTM/rs_gts_portal_3vqd.asp
  • Reporting Services – Deploying a Custom Assembly: http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_rdl_8mue.asp
  • Extending Reporting Services: http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_install_0ur7.asp
  • More Stories By Mike Finley

    Michael Finley, MCSD, is a senior developer analyst at Empowered Software Solutions, a Chicago-based consulting firm and Microsoft Gold Certified Partner. Mike has more than 12 years of expereince developing custom applications in the utility, insurance, and logistics industries and hs presented at the Chicago .NET User Group. He also is the author of SQL ScriptSafe, which is a shareware .NET application that integrates Visual SourceSafe and SQL Server (www.sqlscriptsafe.com).

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    IoT & Smart Cities Stories
    Moroccanoil®, the global leader in oil-infused beauty, is thrilled to announce the NEW Moroccanoil Color Depositing Masks, a collection of dual-benefit hair masks that deposit pure pigments while providing the treatment benefits of a deep conditioning mask. The collection consists of seven curated shades for commitment-free, beautifully-colored hair that looks and feels healthy.
    The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
    The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
    We all love the many benefits of natural plant oils, used as a deap treatment before shampooing, at home or at the beach, but is there an all-in-one solution for everyday intensive nutrition and modern styling?I am passionate about the benefits of natural extracts with tried-and-tested results, which I have used to develop my own brand (lemon for its acid ph, wheat germ for its fortifying action…). I wanted a product which combined caring and styling effects, and which could be used after shampo...
    The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
    There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
    Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
    Druva is the global leader in Cloud Data Protection and Management, delivering the industry's first data management-as-a-service solution that aggregates data from endpoints, servers and cloud applications and leverages the public cloud to offer a single pane of glass to enable data protection, governance and intelligence-dramatically increasing the availability and visibility of business critical information, while reducing the risk, cost and complexity of managing and protecting it. Druva's...
    BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.