Thus, the Report Management web service is often used in combination with the Report Execution web service, and sometimes in combination with URL access.. To access the Report Management
Trang 1Using Reporting Services Web Services
static string GetReportXML_VS2008(string ReportPath){
//creates a new web service (proxy) and sets its credentialsReportExecutionServiceSoapClient rs = new ReportExecutionServiceSoapClient();
//Windows authenticationrs.ClientCredentials.Windows.AllowedImpersonationLevel =System.Security.Principal.TokenImpersonationLevel.Impersonation;
// Setup Render() callbyte[] result = null;
string encoding, mimeType, extension, DeviceInfo=null;
Warning[] warnings = null;
string[] streamIDs = null;
try{string historyID = null;
out SvrInfoHeader, out ExecInfo);
rs.Render(ExecHeader, null, “XML”, DeviceInfo, out result,
out extension, out mimeType, out encoding,out warnings, out streamIDs);
//Gets a byte stream with Comma Separated Value (XML) layoutreturn System.Text.Encoding.ASCII.GetString(result);
}catch (SoapException e){
//Return exception message, if exception occurredreturn e.Message;
}}
Before we can use the preceding code, we must sort out security Notice the following lines
in the code:
Trang 2rs.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
It is a request to WCF to impersonate the user In addition to the code, we need to
prop-erly configure security in the app.configfile You can find the app.configfile in your
project’s folder Double-click it to edit, and ensure that it has the following in the security
section (Note that most of the security section is already set and you just need to fill
missing items, such as clientCredentialType.)
Note that Windowsin the preceding code sample is case sensitive
You may see the following exception if security is improperly configured:
Message=”The HTTP request is unauthorized with client authentication scheme
‘Anonymous’ The authentication header received from the server was ‘Negotiate,NTLM’.”
You may see this exception if you do not have sufficient privileges to access:
An unhandled exception of type ‘System.Net.WebException’
occurred in system.web.services.dll Additional information:
The request failed with HTTP status 401: Unauthorized
The following is an exception if you do not request to impersonate a user:
Message=”The HTTP request is unauthorized with client authentication scheme ‘Ntlm’
The authentication header received from the server was ‘NTLM’.”
Also notice:
<client>
<endpoint address=http://127.0.0.1:80/ReportServer/ReportExecution2005.asmx
This is an address of theReportExecution2005services end In the preceding example, it
is pointing to thelocalhost(127.0.0.1) port80 If you need to configure your
applica-tion to use another SSRS, you can just modify the endpoint address
A call to GetReportXML_VS2008as shown here demonstrates an assignment of the
/Samples/DemoListreport in the XML form to a text box textBoxResult:
textBoxResult.Text = GetReportXML_VS2008(“/Samples/DemoList”);
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 3Do not forget to change the format string to HTML if you need to get HTML output forthe application
Most parameters in the Render()function are optional and accept nullvalues
Warning[] warnings;contains an array of objects with information about errors andwarnings for which SSRS did not generate exceptions In production code, you need tomake sure to incorporate handling for warnings
The example uses part of the information available in SoapException.SoapExceptionhasfour properties:
Actor: The code that caused the exception
Detail: The XML describing application-specific error information Detailis an
XMLNodeobject, and inner text from Detailcan be accessed for the flow control (forexample,if(ex.Detail[“ErrorCode”].InnerXml == “rsItemNotFound”) {/*handlethe error*/})
HelpLink: A link to a Help file associated with the error
Messsage: A message describing the error
The Report Execution web service is very sensitive to the report’s path, requires the path
to start from /(slash), and does not accept URL-encoded strings If the path is incorrect,the web service returns an ItemNotFoundExceptionorInvalidItemPathExceptionexcep-tion For example, for a report with the name My DemoList (note the space after the word
My) located in the Samples directory, the URL-encoded path /Samples/My%20DemoListisnot acceptable It would cause an error with an exception similar to the following:
System.Web.Services.Protocols.SoapException: The item
‘/ReportProject/Top%20SalesPeople’
cannot be found —->
Microsoft.ReportingServices.Diagnostics.Utilities.ItemNotFoundException:
The item ‘/ReportProject/Top%20SalesPeople’ cannot be found
If SSRS is configured in native mode and the path does not start with a slash, SSRS atesInvalidItemPathException:
Trang 4If the report server is in native mode, the path must start with slash.
The proper way to enter this path is/Samples/My Demolist(prefixed with slash when SSRS
is in the native mode and without URL encoding)
Actions inGetReportXML_VS2008 ()should produce the same result as
http://localhost/ReportServer/ReportExecution2005.asmx?/Samples/DemoList&rs:
Command=Render&rs:Format=XML The difference is that the web service call is not
interac-tive, but the web service call allows an application to receive and process a report’s XML
internally
System.Text.Encoding.ASCII.GetStringis used to convert a byte[]array that Render()
returns to a string Note that ASCII is an option suitable for text-based formats, such as
XML and CSV Other converters (such as Unicode) are available in the
System.Text.Encodingnamespace
As a comparison, to use NET 2.0 web services style code, you follow steps 1 through 4
above to access the Add Service Reference dialog box and then complete the following steps:
1 Access the Add Web Reference dialog box by clicking the Advanced button on the
Add Service Reference dialog box
2 Enterhttp://<server>/ReportServer/ReportExecution2005.asmxin the URL field
3 Click Go
4 Set Web Reference Name to ReportExecution2005_VS2005(see Figure 28.3)
5 Click Add Reference Under the project folder, note the Web References folder
6 Add web references:
using EmbeddedReport.ReportExecution2005_VS2005;
using System.Web.Services.Protocols;
7 And add the following code:
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 5Using Reporting Services Web Services
static string GetReportXML2005(string ReportPath){
//creates a new web service (proxy) and set its credentialsReportExecutionService rs = new ReportExecutionService();
//windows authenticationrs.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Assign web service URL This is optional operation Default URL
//is assigned during the creation of a proxy
//Typically http://<<server name>>/ReportServer/ReportExecution2005.asmx//rs.Url = ReportingServicesURL;
// Setup Render() callbyte[] result = null;
string encoding, mimeType, extension;
Warning[] warnings = null;
string[] streamIDs = null;
try{//Should be called prior to Render() to set report’s pathFIGURE 28.3 Add Web Reference dialog box
Trang 6//Return exception message, if exception occurredreturn e.Message;
}}
The line rs.Credentials = System.Net.CredentialCache.DefaultCredentials;is very
important An application must supply credentials to the SSRS web service before the
application can access a report DefaultCredentialsis the Windows authentication for
the user
Report Management Web Service ( ReportService
2005.asmx)
Previously in this chapter, you saw an example of the Report Execution web service
(ReportExecution2005.asmx) Most of the report-execution functionality is available using
URL access
In contrast, only a few URL access methods (such as ListChildren()) are available from
the Report Management web service (ReportService2005.asmx) Thus, the Report
Management web service is often used in combination with the Report Execution web
service, and sometimes in combination with URL access The combination of various
access methods provides the most comprehensive access to SSRS
NOTE
The following examples use Visual Studio 2005 NET 2.0 style We explained the
differ-ence between Visual Studio 2008 NET 3.5 WCF-style samples and Visual Studio 2005
.NET-2.0 style samples previously in this chapter
To access the Report Management web service, you can follow the same steps used earlier
to access the Report Execution web service:
1 Add a web reference to the Report Management web service
(ReportService2005.asmx)
2 Name the proxy ReportService2005.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 74 Call Report Management web service methods.
The following is an example of a console application returning items stored on SSRS ing from the root/folder:
class Program{
static void Main(string[] args){
//creates new Web service (proxy) and set its credentialsReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
try{CatalogItem[] items = rs.ListChildren(“/”, true);
Console.Write(“Item Path, Item Name, Item Type, MimeType”);
foreach (CatalogItem ci in items){
Console.Write(ci.Path + “,” + ci.Name + “,” +
ci.Type + “,” + ci.MimeType + “\n”);
}return;
}catch (SoapException e){
Console.Write(e.Message);
}}}}
Trang 8The RS utility is a scripting utility that enables access to Reporting Services functionality
using Visual Basic NET scripts In scripts, you can define classes and use other
object-oriented functionality of Visual Basic NET
By default, the RS utility is installed in theC:\Program Files\Microsoft SQL
Server\100\Tools\Binndirectory SSRS no longer comes with sample scripts, but you can
download samples from the online community www.codeplex.com/MSFTRSProdSamples/
Release/ProjectReleases.aspx?ReleaseId=16045 You can dissect and modify sample scripts to
fit scenarios at hand Scripting is a convenient way to automate repetitive administrative
tasks or tasks that apply to a group of items
Executing the rs /?command yields the following usage direction:
Microsoft (R) Reporting Services RS
Version 10.0.1600.22 ((SQL_PreRelease).080709-1414 ) x86
Executes script file contents against the specified Report Server
RS -i inputfile -s serverURL [-u username] [-p password]
[-l timeout] [-b] [-e endpoint] [-v var=value] [-t]
-i inputfile Script file to execute-s serverURL URL (including server and vroot) to execute
script against
-u username User name used to log in to the server
-p password Password used to log in to the server
-e endpoint Web service endpoint to use with the script
Options are:
Exec2005 - The ReportExecution2005 endpointMgmt2005 - The ReportService2005 endpoint-l timeout Number of seconds before the connection to the
server times out Default is 60 seconds and 0 isinfinite time out
-b Run as a batch and rollback if commands fail-v var=value Variables and values to pass to the script-t trace Include trace information in error message
The following sample script gets a list of extensions registered with Reporting Services
and, as a bonus, outputs the Report Server version and edition For the purpose of an
example, you can add the following code to the RsUtilTest.rssfile:
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 9rs.ServerInfoHeaderValue.ReportServerVersionNumber)Console.WriteLine(“Report Server Edition:” &
rs.ServerInfoHeaderValue.ReportServerEdition)
Dim Ext As ExtensionDim Type As StringConsole.WriteLine(“Type Name”)For Each Ext In Extensions
Select Ext.ExtensionType
Case ExtensionTypeEnum.DeliveryType = “Delivery”
Case ExtensionTypeEnum.Render
Type = “Render “Case ExtensionTypeEnum.Data
Type = “Data “Case Else
Type = “Other “End Select
Console.WriteLine(Type + “ “ + Ext.Name)Next
End SubReportServerVersionNumberandReportServerEditionare properties of ReportingServices You need to call Reporting Services before the properties are set If you place thiscall after you access Reporting Services properties, those properties will be empty This iswhat we are doing in the following line:
Extension()=rs.ListExtensions(ExtensionTypeEnum.All)
The scripting utility provides an internal reference to Reporting Services through thers
object, which is ready to be used in scripts without an explicit instance creation Thecommand to execute the script might look like the following:
rs -iRsUtilTest.rss -shttp://localhost/ReportServer
Working with Report Parameters
Report parameters are encapsulated by two classes: The ParameterValueclass enablesdevelopers to set and retrieve report parameter values, and the ReportParameterclass isused to get and set properties of a parameter Both ParameterValueandReportParameter
Trang 10code snippet shows how to pass parameters to render a function You can incorporate this
code into the GetReportXML2005()function written earlier in this chapter by adding the
following code inside of the tryblock after LoadReportand through the call to the
func-tionRender, replacing the original Rendercall (Visual Studio 2005, NET 2.0 style):
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = new ParameterValue();
parameters[0].Name = “SalesOrderNumber”;
parameters[0].Value = “SO43659”;
rs.SetExecutionParameters(parameters, “en-us”);
result = rs.Render(format, devInfo, out extension,
out encoding, out mimeType,out warnings, out streamIDs);
Or the following code for Visual Studio 2008, NET 3.5, WCF style Note that the main
differences between WCF and NET 2.0 style, in this case, are in the
SetExecutionParametersandRenderfunction signatures:
ExecutionInfo ExecInfo;
ExecutionHeader ExecHeader;
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = new ParameterValue();
parameters[0].Name = “SalesOrderNumber”;
parameters[0].Value = “SO43659”;
rs.SetExecutionParameters(ExecHeader, null, parameters, “en-us”, out ExecInfo);
rs.Render(ExecHeader, null, “XML”, DeviceInfo, out result, out extension,
out mimeType, out encoding, out warnings, out streamIDs);
In the previous examples, you can see two out of three string properties of the
ParameterValueclass:NameandValue The third property is a Labeland is used as an
alternate name for a parameter
Note the usage of the SetExecutionParameters()function that assigns the parameter and
parameter’s language (because this is optional, you can pass null) to the current execution
of a report
ReportParameteris used in conjunction with GetReportParameters()and
SetReportParameters().GetReportParameters()retrieves a report’s parameters’ properties
(ReportParameterclass) and can validate whether an array of ParameterValuevalues
passed to this function are acceptable for a report SetReportParameters()sets properties
of parameters Table 28.2 outlines commonly used public properties of the
ReportParameterclass
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 11Security When Calling a Web Service (.NET 2.0 Style)
Out of the box, SSRS supports Windows authentication and authorization If you need tohave custom authentication, SSRS provides this through custom authentication (or secu-rity) extensions You have to develop a new security extension to handle custom authenti-cation
.NET Framework greatly simplifies Windows and basic authentication handling throughclasses in the System.Netnamespace
Before deciding which authentication method to use, consider security implications ofeach type of authentication: anonymous, basic, and integrated/Windows
As you might recall, we leveraged the NET Framework to set Windows credentials in the
TABLE 28.2 Commonly Used Public Properties of the ReportParameter Class
Name Description
AllowBlank Indicates whether an empty string is a valid value for the
para-meter
DefaultValues Gets or sets the default value of the parameter
DefaultValuesQueryBased Indicates whether the default values of the parameter are
based on a query
ErrorMessage Indicates the error message returned when a parameter value
has failed validation
MultiValue Indicates whether the parameter is a multivalued parameter
Name Gets or sets the name of a parameter
Nullable Indicates whether the value of the parameter can be nullPrompt Gets or sets the text that prompts the user for parameter
values
PromptUser Indicates whether the user is prompted for the value of the
parameter
QueryParameter Indicates whether the parameter is used in a query
ValidValues Indicates the available ValidValuesobjects for the parameter
ValidValuesQueryBased Indicates whether the parameter’s valid values are based on a
query
Trang 12The credentials must be set before the use of any methods in the SSRS web service Calls
to a web service method before setting credentials receive an error: HTTP 401 Error:
Access Denied
Security When Calling a Web Service (.NET 3.x,
WCF Style)
A detailed WCF security discussion is beyond scope of this chapter, but we do want to
present you with some basic concepts to help you understand what we have done in our
WCF example You can find a detailed WCF security review at http://msdn.microsoft.com/
en-us/library/ms732362.aspx and a pretty good short explanation at
www.code-magazine.com/articleprint.aspx?quickid=0611051
When we added the ReportExecution2005service reference, Visual Studio 2008 added a
service reference and <system.serviceModel>configuration entries in the app.configfile
There are several entries under the <system.serviceModel>tag:
bindings: Describes communication configuration options, including protocol,
configuration, and security
basicHttpBinding: Requests HTTP communications, and compatible with
old-style (.NET 2.0, SOAP 1.1) web services By default, the SOAP message is not securedand the client is not authenticated You can use the securityelement to configureadditional security options There are other types of bindings: NetTcpBindingusedfor binary cross-machine TCP communications, and WSHttpBindingor
WSFederationHttpBindingfor web services that can support richer communicationfunctionality
security: Describes security configuration The security template that VS2008 adds
Trang 13“Basic128” | “Basic192” | “Basic256” | “Basic128Rsa15” |
“Basic256Rsa15” | “TripleDes” | “TripleDesRsa15” |
“Basic128Sha256” | “Basic192Sha256” | “TripleDesSha256” |
“Basic128Sha256Rsa15” | “Basic192Sha256Rsa15” |
“Basic256Sha256Rsa15” | “TripleDesSha256Rsa15”
}clientCredentialType=
{“Certificate” | “IssuedToken” | “None” |
“UserName” | “Windows”
}/>
</security>
Let’s look at additional configuration details:
mode: Requests a specific mode of transfer security basicHttpBindingallows thefollowing options:
None: Default The SOAP message is not secured during transfer
Transport: HTTPS provides integrity, confidentiality, and server tion That is, the service is authenticated by the client using the service’sSecure Sockets Layer (SSL) certificate The service must be configured with SSLcertificate You control client authentication using the ClientCredentialType
authentica- Message: SOAP message security provides security For the BasicHttpBinding,the system requires that the server certificate be provided to the client sepa-rately For BasicHttpBinding, the valid client credential types are UserNameand
Certificate
Trang 14TransportWithMessageCredential: HTTPS provides integrity, tiality, and server authentication That is, the service is authenticated by theclient using the service’s SSL certificate The service must be configured withthe SSL certificate Client authentication is provided by means of SOAPmessage security This mode is applicable when the user is authenticating with
confiden-aUserNameorCertificatecredential, and there is existing HTTPS for securingmessage transfer
TransportCredentialOnly: We use this method in our example It is,
perhaps, the easiest one to use, but use this mode with caution This mode does
not provide message integrity or confidentiality; it provides only HTTP-basedclient authentication You can use it in environments where other methods(such as IPSec) provide the transfer security and client authentication isprovided only by the WCF infrastructure
transport: Configuration for Transportmode of security, including
TransportWithMessageCredentialandTransportCredentialOnly
clientCredentialType: Specifies the type of credential to be used when
perform-ing HTTP client authentication Possible options for this configuration are as follows:
None: Anonymous authentication
Basic: Basic authentication
Digest: Digest authentication
Ntlm: Client authentication using NTLM
Windows: Client authentication using Windows
Certificate: Client authentication using a certificate
proxyCredentialType: Specifies the type of credential for client tion in a domain using a proxy over HTTP This attribute is applicable onlywhen the modeattribute is set to TransportorTransportCredentialsOnly Theavailable options for this configuration are the same as for
authentica-clientCredentialType(discussed earlier) In our example, we left this tication as None, but it also works if you set it to the same value as
authen-clientCredentialType, or Windowsin the case of our example
realm: A string that specifies a realm (or an independent resource partition) that is
used by digest or basic HTTP authentication
In our WCF example, we leveraged the NET Framework System.Securityclass to set
Windows credentials in the GetReportXML2005()method earlier in this chapter:
rs.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 15<transport clientCredentialType=”Windows” proxyCredentialType=”None”
Using SSL to Increase Security
To increase security, an administrator can use SecureConnectionLevelto configure SSRSand enforce web service client applications to leverage various levels of SSL communica-tions for Report Server web service method calls (This configuration also affects ReportManager.)
SSRS usesSecureConnectionLevel(located inRSReportServer.config) to determine whichweb service methods require an SSL connection The default is0(noted in the configura-tion as<Add Key=”SecureConnectionLevel” Value=”0” />).SecureConnectionLevelhasfour levels that affect URL and SOAP interfaces that SSRS exposes:
0: SSRS does not check for secure connections (SSL) Method calls can still be madeover SSL (HTTPS) connections, if needed
1: SSRS checks for secure connections If SSL is not available, the web service rejectsthe method (such as CreateReport()andGetReportDefinition()) calls that canpass sensitive information (such as user credentials) Because this setting is checked
at the server, it is still possible to make a call that passes credentials before the webservice handles the request Method calls can still be made over SSL (HTTPS) connec-tions, if needed Because Render()is not restricted by this setting, it might be possi-ble for a hacker to intercept sensitive data from a report
2: Most method calls, including Render(), are required to use SSL
3: All method calls are required to use SSL In this case, SSRS requires SSL/HTTPS forall web service method calls
You can find more information about using secure web service methods at http://msdn
microsoft.com/en-us/library/ms154709.aspx
In addition, you can find information about how to configure SSRS with SSL at http://technet.microsoft.com/en-us/library/ms345223.aspx
Trang 16Some of the Commonly Used Methods with Short
Code Snippets
All snippets require a proper SSRS endpoint reference as described earlier in the chapter,
web and SOAP proxy references, and the following calls prior to calling any of the
methods:
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
Although the examples use VS2005 NET 2.0 style, you can still use the style in Visual
Studio 2008 as we have discussed earlier in this chapter, or you can modify the samples to
use VS2008 NET 3.5 WCF style
Find and cancel all jobs:
Job[] jobs = null;
jobs = rs.ListJobs(); //Get a list of current jobs
foreach (Job job in jobs){
if (job.Status == JobStatusEnum.Running || job.Status ==
JobStatusEnum.New){
rs.CancelJob(job.JobID);
}}
Create a folder item:
rs.CreateFolder(strFolderName, strParentFolderName, null);
Create a report item:
FileStream stream = File.OpenRead(“sample.rdl”);
Byte[] rdl = new Byte[stream.Length];
stream.Read(rdl, 0, (int) stream.Length);
stream.Close();
rs.CreateReport(strReportName, strFolderName, false, rdl, null);
Delete an item:
rs.DeleteItem(strItemPath)
Get an RDL of a report from SSRS:
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
byte[] reportDefinition = rs.GetReportDefinition(strReportName);
MemoryStream stream = new MemoryStream(reportDefinition);
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 17BatchHeader bh = new BatchHeader();
is frequently used to automate high-volume management tasks: report deployment, rity management, and so on
Trang 18Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 19Report DefinitionCustomization Extension
Delivery Extension
Interactions Between User,SSRS, and a Delivery Extension
Custom Report Items
SSRS is designed for extensibility In the previous chapters,
you learned how to extend SSRS reporting capabilities by
writing custom code that can be called from a report
Extensions, on the other hand, are called by SSRS
Extensions are composed of four key categories: security,
delivery, data processing, and rendering (see Chapter 2,
“Reporting Services 2008 Architecture”) SSRS 2008 adds a
new type of extension called Report Definition
Customization Extension (RDCE), which allows
customiza-tion of Report Definicustomiza-tion Language (RDL) at runtime RDCE
is explained later in this chapter
Typical extensions installed with SSRS are as follows:
Data processing: Microsoft SQL Server, Microsoft
SQL Server Analysis Services, Oracle, SAP NetWeaver
BI, Hyperion Essbase, Teradata, OLE DB, ODBC, XML,SAP BW, Essbase, and Teradata
Delivery: File share, email, document library, null.
Note that not all delivery extensions are compatiblewith all rendering extensions; for example, most ofthe delivery extensions exclude null rendering fromthe processing
Render: Excel, MHTML, HTML 4.0 (Microsoft
Internet Explorer 5.0 or later), PDF, Image (graphicalimage output, such as TIF, GIF, JPG), CSV, XML, null(used to place reports in cache and in conjunctionwith scheduled execution and delivery), RGDI (formatused for Windows Forms ReportViewercontrol), andRPL (Report Page Layout format is an intermediateformat that the processing engine creates and that is
Trang 20consistency across rendering format The object model for RPL is not publiclyexposed in the 2008 release.)
Other:SemanticQueryandModelGenerationto extend Report Builder’s
functional-ity EventProcessingto act on the events generated by Report Server
Security: By default, SSRS uses Windows integrated authentication.
A complete list of extensions installed on a particular instance of SSRS can be retrieved by
callingReportingService2005.ListExtensions(ExtensionTypeEnum.All) or by examining
thersreportserver.configfile
Rendering is, perhaps, the most developed category of extensions With a wide range of
rendering extensions and a multitude of applications (including Microsoft Office) that
“understand” HTML, it is hard to think of a new rendering extension that would be
immediately useful
Some of the SSRS capabilities that customers are frequently looking for and that are
currently not available “out of the box” are as follows:
Printer (fax) delivery: An ability to print (fax) batches of reports without human
interactions
Custom authentication: An ability to authenticate non-Windows clients
It is possible to work around the need to have certain functionality For example, instead
of delivery to a printer directly from SSRS, an administrator can configure delivery of a
report to a file share and have a separate process monitoring and printing from such a file
share by using the Windows PRINTcommand (for example, PRINT /D:\\<server
URL>\<printer name> <files to print>)
It is also possible to work around the scenario in which users cannot use Windows
authentication An administrator can create a Windows account for a user, configure
Internet Information Services (IIS) to accept basic authentication (must enable Secure
Sockets Layer [SSL] for better security), and ask the user to enter Windows credentials to
access a report
Although it is possible to work around some of the limitations, custom extensions can
offer elegant solutions to supplement missing functionality
A custom extension is a private or shared NET assembly with a unique namespace (the
specific assembly name is not important, but it must be unique), and a class that
imple-ments the IExtensioninterface and one or more interfaces shown in Table 29.1 To
improve chances for an assembly to have a unique name, you can prefix it with the name
(or abbreviation) of your company
As with any NET implementation, Visual Studio is the most frequently used development
tool for development of assemblies and, therefore, extensions Unless we specified
other-Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 21Extending Reporting Services
TABLE 29.1 Frequently Used Subset of Interfaces for Custom Extensions
Interface(s) Applies to an
ExtensionCategory
Description
IAuthenticationExtension Security Implementation of this interface extends
the authentication feature of SSRS Thisinterface extends IExtension
IAuthorizationExtension Security Implementation of this interface extends
the authorization feature of SSRS Thisinterface is not Common LanguageSpecification (CLS)-compliant This meansthat not all NET languages can call orimplement this interface; also C# andVB.NET can deal with this interface justfine This interface extends IExtension
(Optional) and required interfaces of aclass that implements a data-processingextension Those interfaces are modeledafter NET data provider interfaces anddefined in the Microsoft.ReportingServices.DataProcessingnamespace
IDeliveryExtension Delivery Implementation of this interface interacts
with SSRS to share and validate an sion’s settings and to execute delivery
exten-This interface extends IExtension
IDeliveryReportServerInformation
Delivery Implementation of this interface is used
in conjunction with IDeliveryExtension.SSRS supplies information about itselfthrough this interface
data, delivery, and rendering extensions
Implementation of IExtensionprovideslocalized extension name and extension-
wise, an interface mentioned in the Table 29.1 is a part of the following NET library:
Microsoft.ReportingServices.Interfaces
Trang 22TABLE 29.1 Continued
Interface(s) Applies to an
ExtensionCategory
Description
information about a parameter: Name,
IsMultivalue, and Values
IRenderStream Rendering Implementation of this interface provides
support for multiple streams renderingfrom a rendering extension
IRenderingExtension Rendering Implementation of this interface is
required for a rendering extension so thatthe extension is recognized by SSRS Thisinterface is defined in the Microsoft
Report-defini-Implementation of the IReportDefintionCustomizationExtension
interface gets an RDL as input, andreturns modified RDL and Trueif thereport was modified
This interface extends the IExtension
interface
IReportContext,IUserContext, and
IParameterprovide the report and usercontext and parameters for the RDL beingprocessed
[ISubscriptionBaseUIUser
Control]
Delivery Implementation of this interface provides
a subscription UI for the Report Manager
This interface is what shows data-entryfields For example, in the case of anemail, it displays an interface to enter aTo: email address and so on This inter-face extends IExtension This interface
is optional because a subscription can becreated using SOAP API methods
CreateSubscriptionandCreateDataDrivenSubscription The class thatinherits from this interface must alsoinherit from System.Web
UI.WebControls.WebControl
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 23The reporting library provides three namespaces that supply interface definitions, classes,and value types that allow extensions to interact with SSRS:
Microsoft.ReportingServices.DataProcessing: Used to extend the processing capability of SSRS
data- Microsoft.ReportingServices.Interfaces: Used to build delivery and rity extensions
secu-This namespace also enables you to maintain a cross-connection state A class thatimplements the IExtensioninterface from this namespace is kept in memory for aslong as SSRS is running
Microsoft.ReportingServices.ReportRendering: Used to extend the dering capabilities of SSRS This namespace is used in conjunction with the
ren-Microsoft.ReportingServices.Interfacesnamespace
Before you can successfully compile an extension, you must supply the reference to one ormoreMicrosoft.ReportingServicesnamespaces as follows:
using Microsoft.ReportingServices.Interfaces;
A namespace can have optional interfaces, such asIDbConnectionExtensionin
Microsoft.ReportingServices.DataProcessing, and required interfaces, such as
IDbConnectionin the same extension’s namespace When an interface is required and adeveloper chooses not to implement a particular property or method of the interface, it is
a best practice to throw aNotSupportedException.NotSupportedExceptionis most priate for this purpose as it indicates methods (and properties) that did not provideimplementation for methods described in the base classes (interfaces) The next best alter-native isNotImplementedException Note that optional interfaces do not require imple-mentation at all
appro-NOTE
If you have chosen not to implement a particular property or method of the required
interface, choose NotSupportedExceptionfor clear identification
Optional interfaces do not require implementation at all
Any CLR application interacts with the CLR security system This book briefly covered the
Trang 24Administrator.” The same principles apply to extensions Local security settings and SSRS
configuration files define the code permissions that an extension’s assembly receives SSRS
extensions must be a part of a code group that has the FullTrustpermission set
To deploy an assembly, an SSRS administrator must have appropriate permissions to write
to the Report Server directory, Report Designer directory, and configuration files
When a Report Server first loads an extension in memory, the Report Server accesses an
assembly using service account credentials Service account credentials are needed so that
an extension can read configuration files, access system resources, and load dependent
assemblies (if needed) After an initial load, the Report Server runs an assembly using
credentials of the user who is currently logged in
An extension can be deployed for use by the Report Server, Report Manager, Report
Designer, or all of these This is provided that the extension can be used by a tool For
example, Report Manager uses only delivery extensions
The deployment procedure for an extension used by the Report Server, Report Manager, or
Report Designer is basically the same The only difference is the deployment directory and
configuration files that need to be modified To simplify further discussion, this book uses
the following abbreviations:
{AssmDir}: To abbreviate assembly deployment directories The default Report
Server binary directory is C:\Program Files\Microsoft SQL Server\
MSRS10.MSSQLSERVER\Reporting Services\ReportServer\bin The default ReportDesigner binary directory is C:\Program Files\Microsoft Visual Studio9.0\Common7\IDE\PrivateAssemblies The default Report Manager binary directory
isC:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\ReportingServices\ReportManager\bin
{ConfigFile}: To abbreviate configuration files (note the default file path) The
default location for the Report Server configuration file is C:\ProgramFiles\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\
ReportServer\RSReportServer.config The default location for the Report Designerconfiguration file is C:\Program Files\Microsoft Visual Studio
9.0\Common7\IDE\PrivateAssemblies\RSReportDesigner.config A separate ReportManager configuration file (RSWebApplication.config) has been deprecated in thisrelease, and the Report Manager uses RSReportServer.configconfiguration instead
{SecConfig}: To abbreviate security configuration files The default location for the
Report Server security configuration file is C:\Program Files\Microsoft SQLServer\MSRS10.MSSQLSERVER\Reporting Services\ReportServer\RsSrvPolicy
config The default location for the Report Designer security configuration file is
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\
RSPreviewPolicy.config The default location for the Report Manager security uration is C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\ReportingServices\ReportServer\RsMgrPolicy.config
config-Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 25Common Considerations for Custom Reporting Services Extensions
To deploy an extension, a report administrator can use the following steps:
1 Copy an extension assembly to the{AssmDir}directories Remember that
{AssmDir}is an abbreviation that denotes three different directories If an assemblywith the same name that you are trying to deploy exists in one of the{AssmDir}
directories, stop the Report Server Service, copy an assembly, and then restart theReport Server Service
2 Locate an entry in the {ConfigFile}under the <Extensions>tag that corresponds to
a category ({ExtCategory}) of an extension: <Delivery>,<Data>,<Render>,
<Security>(authorization),<Authentication>, or <DeliveryUI>
3 Add an entry for a newly created extension to a {ConfigFile}:
<Extensions>
<(ExtCategory}>
<ExtensionName=”{Unique extension name up to 255 characters}”
Type=”{Fully qualified name of the class implementing IExtension},{AssemblyName without dll}”
Visible=”{false|true; false indicates that extension is not visible