Due to the rising popularity of Rich Internet Applications (RIA) e.g. Silverlight applications, the developers get more dependent on services for coordinating application logic between the middle tier and the presentation tier and the logical question raises how to use an already working WCF RIA Service as a datasource for Telerik Report. This is very useful if you want to enable the exact same business data access logic for clients other than Silverlight. For example to a WPF, WinForms or WebForms application. Thus we have made some tests locally and decided to share our observations in this post.
We will examine the WCF RIA services from Telerik Reporting point of view, so previous basic knowledge on WCF, RIA Services and Telerik Reporting is required and will help you understand the key concepts below. If you are new to this technology the WCF RIA Services Get Started page is the ideal place to start. Another recommended reading is the MSDN Walkthrough: Creating a RIA Services Solution article. We have included a sample WCF RIA service that uses the AdventureWorks database that we would use for our tests.
What you should have installed prior starting:
In Telerik Reporting, Reports represent an abstract definition of the data to be displayed and the way it is displayed. At runtime the reports are processed and rendered by the reporting engine. Its main responsibilities are to extract the data from the data sources and render it according to the layout and styles from the Report definition. There are two ways one can interact with the report processor:
In RIA Services, you expose data from the server project to client project by adding domain services. The RIA Services framework implements each domain service as a Windows Communication Foundation (WCF) service. Therefore, you can apply the concepts you know from WCF services to domain services when customizing the configuration. For more information, see Domain Services article.
As explained above, the reporting engine accesses the data from the data source. When it comes to consuming that data from a WCF RIA service and depending on the domain service location, we recognize two scenarios:
In this scenario the domain service is hosted in a process different than the one hosting the reporting engine. In order to consume data from such domain service one should create a service client and use it through the ObjectDataSource Component.
To set a WCF RIA Service as datasource for Telerik Reporting you have to:
Note: In order to consume domain services from clients other than Silverlight you have to enable SOAP endpoints for your WCF RIA service. A nice explanation on this matter is available in the Silverlight 4 + RIA Services - Ready for Business: Exposing WCF (SOAP\WSDL) Services post.
In this scenario the reporting engine and the domain service reside in the same application. This means that the reporting engine can use the domain service class as you do with any other .NET class withough the need of the WCF infrastructure.
Again you use the ObjectDataSource to connect to the domain service class.
Having the domain service on site, means that you most probably have access to the data model which means that you can even use it as a report data source. For example if this is ADO.NET Entity Data Model you can use the EntityDataSource Component to connect the report to the data model.
Note: Currently the Report Designer can't get the schema of the data source because of WCF RIA services' peculiarities. Thus be aware that the available wizards and Data Explorer would not be populated with data source fields and both Previews would not work.
WCF RIA Services simplifies the development of n-tier solutions and gives excellent separation of the data and application logic from the presentation. In combination with the powerful WCF technology you can create Rich Internet Applications (RIA) with the best user experience without the need to develop and maintain the same application logic on both server and client sides. The two technologies together allow the Telerik Reporing engine to consume data from any WCF RIA Services in a seamless manner without breaking the best architecture patterns.
Click here to download a sample solution that contains both approaches.
Stefan’s main interests outside the .NET domain include rock music, playing the guitar and swimming.
Subscribe to be the first to get our expert-written articles and tutorials for developers!