Silverlight Viewer for Reporting Services Getting Started (Local
Connection)
Download as PDF: GettingStartedSSRS2005LocalConnection.pdf
PLEASE BE ADVISED THAT LOCAL REPORTS GENERATION IS POSSIBLE ONLY
WITH SILVERLIGHT VIEWER FOR REPORTING SERVICES 2005 AND VISUAL STUDIO 2008.
Creating Web application using the build-in report processing.
Prerequisites
- .NET Framework 3.5 SP1
- Silverlight v3
- Silverlight v3 SDK
- Silverlight v3 Developer Tool
- Visual Studio 2008
- Microsoft SQL Reporting Services Sample Reports
Attachment
SilverlightViewerForReportingServicesGettingStartedForLocalConnectionSample.zip
Introduction
The target of the following guide is to demonstrate the basic
moments of the use of Silverlight Viewer for Reporting Services. It gives minimum
necessary knowledge in order to start working with the component. We will examine
the process of generation of web application with the use of Silverlight Viewer
for Reporting Services step by step. We will consider creation and configuration
of the service and at last integration of the report viewer component on the application
pages.
Creating Web application
Step 1.
Create a new Silverlight Application project named SampleApplication.

While creation of the project select the menu item “Add a new
ASP.NET Web project to the solution to host Silverlight” and set name of the web-project
to SampleApplication.Server.

Step 2.
Set specific port to 5555 in the “Web” tab of the SampleApplication.Server
properties (in the "Solution Explorer", item “Properties” in contextual
menu of the SampleApplication.Server).

Next, set SampleApplication.Server project as Startup Project.

Step 3.
Add Perpetuumsoft.Reporting.Silverlight.Server.Core and PerpetuumSoft.Reporting.Silverlight.Server.ReportingServices
assemblies to the project references, (in "Solution Explorer", item “Add
Reference” in context menu of SampleApplication.Server). These assemblies are located
in the Bin folder of the Silverlight Viewer for Reporting Services installation
folder.

Step 4.
Add WCF service named ReportService.svc to the SampleApplication.Server
project.

Inherit a new ReportService class from the MsReportServiceBase
class for implementation and opportunity to change standard behavior. In order to
make ASP.Net context available for the service, service class needs to be marked
by a special AspNetCompatibilityRequirements attribute. The ASP.Net context is required
for the service to cache document data, if other mechanism of data storage is not
implemented.
// ReportService.svc.cs
using System.ServiceModel.Activation;
using PerpetuumSoft.Reporting.Silverlight.Server.ReportingServices;
namespace SampleApplication.Server
{
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Required)]
public class ReportService : MsReportServiceLocal
{
}
}
Step 5. Now it’s necessary to setup created web-service. Make
changes in the web.config file. System.serviceModel section must be as follows:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name=
"SampleApplication.Server.ReportServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service
behaviorConfiguration=
"SampleApplication.Server.ReportServiceBehavior"
name="SampleApplication.Server.ReportService">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConf"
contract=
"PerpetuumSoft.Reporting.Silverlight.Server.Core.IReportService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint
address="rest"
behaviorConfiguration="webBehavior"
binding="webHttpBinding"
bindingConfiguration="webHttpBindingConf"
contract=
"PerpetuumSoft.Reporting.Silverlight.Server.Core.IReportServiceResources"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingConf"/>
</webHttpBinding>
<basicHttpBinding>
<binding name="basicHttpBindingConf"/>
</basicHttpBinding>
</bindings>
</system.serviceModel>
The first endpoint is intended for work with the report, for
instance, to get pages. The second endpoint is intended for work with the resources,
for instance, to get localization. And, at last, the third endpoint is used to get
meta-information about the service.
The Report Service can work over SSL. To do it you need extended
service definition in the web.config file. Add some definition into binding element.
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
NOTE: If you set Security Mode equal to Transport you have to
set ServiceUrl of ReportViewer to “https://...”
Example:
<webHttpBinding>
<binding name="webHttpBindingConf">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="basicHttpBindingConf">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
Step 6.
Now it’s necessary to set data source and report template. In
order to do this you should add named DataSet to project (in "Solution Explorer",
item “Add -> New Item” in context menu of SampleApplication.Server). Select “Data”
item and then “DataSet” item. Enter NWindDataSet.xsd in the Name field and click
“Add”.

Now you need to add TableAdapter to DataSet. In DataSet Designer
press “Add -> Table Adapter…”

Firstly, press the “New Connection…” button in TableAdapter Configuration
Wizard. Select “Microsoft Access Database File” in the “Choose Data Source” window
and click the “Continue” button.

Click the “Browse” button in the “Add Connection” window and
select database file: NWIND.MDB. This file is located in the Resources\Data folder
of the Silverlight Viewer for Reporting Services installation folder. Leave the
User name and Password fields empty and click “OK”.

Click “Next” after you completed the creation of a new NWIND.MDB
data connection.

Press “Yes” to copy the file to the App_Data folder of the SampleApplication.Server
project.

Secondly, select the “Use SQL statements” item in TableAdapter
Configuration Wizard and press the “Next” button.
Thirdly, add the following SQL statement to field in TableAdapter
Configuration Wizard and click “Finish”.
SELECT EmployeeID, LastName, FirstName, Address, Photo, Notes
FROM Employees
Now you need to add a new Report file to the project (in "Solution
Explorer", item “Add -> New Item” in context menu of SampleApplication.Server).
Select the “Reporting” item and then the “Report” item. Rename the report to "Employees.rdlc".

Now create a report template with Visual Studio 2008 methods
and use data from NWindDataSet.

At last, data source should be set to ReportService in special
overriden GetReportDataSources method inherited from MsReportServiceLocal.
public override IList<LocalReportDataSource>
GetReportDataSources(string reportName,
PerpetuumSoft.Reporting.Silverlight.Server.Core.ReportParameter[]
reportParameters)
{
List<LocalReportDataSource> result
= new List<LocalReportDataSource>();
if (reportName == "Employees.rdlc")
{
EmployeesTableAdapter ta =
new EmployeesTableAdapter();
result.Add(new LocalReportDataSource
("NWindDataSet_Employees", ta.GetData()));
}
return result;
}
You can use report name and it’s parameters values to create
the list of data source objects.
Step 7.
It’s necessary to add the report viewer component to the Silverlight
application for the report display. Therefore you should add a reference to the
PerpetuumSoft.Reporting.Silverlight.MsReporting.Client assembly, containing ReportViewer
(in "Solution Explorer", item Add Reference in context menu of SampleApplication).
This assemble is located in the Bin folder of the Silverlight Viewer for Reporting
Services installation folder.

Open MainPage.xaml in the markup designer and add xml namespace
for the PerpetuumSoft.Reporting.Silverlight.MsReporting.Client assembly.

Then add ReportViewer and set ServiceUrl="http://localhost:5555/ReportService.svc"
and ReportName="Employees.rdlc".
NOTE: We suppose you have Microsoft SQL Reporting Services installed
and configured.

Open the MainPage.xaml.cs source code and add the following code.
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{
reportViewer.ApplyTemplate();
reportViewer.RenderDocument();
}
}
RenderDocument method invocation leads to the rendering of the
current report on the server and its displaying in the Report Viewer.
Step 9.
Set the SampleApplication.Server application as a starting one
and launch it.

Conclusion
We have examined basic steps and got a simple and quite operable
application. We didn’t have to write thousand lines of code – we only used ready-made
implementation. It will be enough in the most cases. If required behavior differs
greatly from the one provided by default, you can change not only many aspects of
the Silverlight Viewer for Reporting Services work but also the appearance of the
report viewer.
ssrs Silverlight Viewer for Reporting Services Local Connection