With the 2010 Q1 SP1 release of Telerik Reporting we have introduced Self-Hosted Reporting WCF Service. In the following blog we are explaining how to use our new feature.
First lets highlight the advantages of the Self-Hosted services:
For the service we choose to operate at address http://localhost:54321.
namespace TelerikReportingServiceHostApp{ [System.Runtime.Serialization.KnownType(typeof(object[]))] class ReportService : Telerik.Reporting.Service.ReportServiceBase { static readonly Uri baseUri = new Uri("http://localhost:54321/reportservice"); protected override Uri BaseAddress { get { return baseUri; } } }}namespace TelerikReportingServiceHostApp{ class Program { static void Main(string[] args) { System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(TelerikReportingServiceHostApp.ReportService)); host.Open(); // Block the Main() method until the user presses a key; then close the host and exit the program Console.WriteLine("Ready..."); Console.ReadLine(); host.Close(); } }}<?xml version="1.0" encoding="utf-8" ?><configuration> … <system.serviceModel> <services> <service name="TelerikReportingServiceHostApp.ReportService" behaviorConfiguration="ReportServiceBehavior"> <host> <baseAddresses> <add baseAddress="http://localhost:54321"/> </baseAddresses> </host> <endpoint address="ReportService" binding="basicHttpBinding" contract="Telerik.Reporting.Service.IReportService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="ReportService/resources" binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="Telerik.Reporting.Service.IResourceService"/> <endpoint address="" binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="Telerik.Reporting.Service.IClientAccessPolicy"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ReportServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="WebBehavior"> <webHttp /> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel>… </configuration>namespace TelerikReportingServiceHostApp{ using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using Telerik.Reporting; using Telerik.Reporting.Drawing; public class Report1 : Telerik.Reporting.Report { public Report1() { Telerik.Reporting.TextBox textBox1 = new Telerik.Reporting.TextBox(); textBox1.Location = new Telerik.Reporting.Drawing.PointU(Unit.Inch(0.3), Unit.Inch(0.3)); textBox1.Size = new Telerik.Reporting.Drawing.SizeU(Unit.Inch(3.4), Unit.Inch(0.4)); textBox1.Value = "Hello, self-hosted Telerik Reporting WCF Service :-)"; Telerik.Reporting.DetailSection detail = new Telerik.Reporting.DetailSection(); detail.Height = Unit.Inch(1); detail.Items.Add(textBox1); this.Items.Add(detail); } }}http://localhost:54321/reportservice/resources/export?format=PDF&report=TelerikReportingServiceHostApp.Report1,TelerikReportingServiceHostApp&deviceInfo={}¶meterValues={}
This will call the IResourceService. Export operation that will render the TelerikReportingServiceHostApp.Report1 in PDF with no deviceInfo or parameterValues. When completed, a PDF document will be sent back to the browser.
Stefan’s main interests outside the .NET domain include rock music, playing the guitar and swimming.