New to Telerik Reporting? Download free 30-day trial

Using Custom Bindings for ReportServiceClient

The Silverlight Report Viewer and its WCF Reporting Service are no longer supported and deployed with the installation of Telerik Reporting. The last release of Telerik Reporting with included Silverlight Report Viewer is R1 2023.

You might encounter a need to use custom Bindings for the ReportServiceClient in certain scenarios. To do that create your own ReportServiceClient object instance and initialize it according to your needs.

You need to implement the IReportServiceClientFactory interface and its only method should create and return a new instance of the ReportServiceClient class using any of its constructors. This way you attach your custom Binding to be used for connecting to the Report Service.

Once you have implemented IReportServiceClientFactory, you should provide an instance to the report viewer so it will use it the next time it creates a new instance of the ReportServiceClient - that is when the report or report service Uri have changed or the RefreshReportCommand is executed through the ReportViewerModel.

The ReportViewer usually passes absolute Uri to the IReportServiceClientFactory.Create() method. For more information on how the ReportServiceUri is resolved to absolute please review Telerik.ReportViewer.Silverlight.ReportViewer.EnsureAbsoluteUri.

The example below illustrates how to implement and use a custom IReportServiceClientFactory:

using System;
using System.ServiceModel;
using System.Windows.Controls;
using Telerik.Reporting.Service.SilverlightClient;
using Telerik.ReportViewer.Silverlight;

public partial class MainPage : UserControl, IReportServiceClientFactory
{
    public MainPage()
    {
        InitializeComponent();

        this.ReportViewer1.ReportServiceClientFactory = this;
    }

    ReportServiceClient IReportServiceClientFactory.Create(System.Uri remoteAddress)
    {
        var binding = new BasicHttpBinding() // or BasicHttpBinding(BasicHttpSecurityMode.Transport) overload if SSL is used
        {
            MaxBufferSize = int.MaxValue,
            MaxReceivedMessageSize = int.MaxValue,
            ReceiveTimeout = new TimeSpan(0, 15, 0),
            SendTimeout = new TimeSpan(0, 15, 0)
        };

        var endpointAddress = new EndpointAddress(remoteAddress);

        return new ReportServiceClient(binding, endpointAddress);

    }
}
Imports System
Imports System.ServiceModel
Imports System.Windows.Controls
Imports Telerik.Reporting.Service.SilverlightClient
Imports Telerik.ReportViewer.Silverlight

Partial Public Class MainPage
    Inherits UserControl
    Implements IReportServiceClientFactory

    Public Sub New()
        InitializeComponent()

        Me.ReportViewer1.ReportServiceClientFactory = Me

    End Sub

    Function Create(ByVal remoteAddress As Uri) As ReportServiceClient Implements IReportServiceClientFactory.Create

        Dim binding = New BasicHttpBinding()
        binding.MaxBufferSize = Integer.MaxValue
        binding.MaxReceivedMessageSize = Integer.MaxValue
        binding.ReceiveTimeout = New TimeSpan(0, 15, 0)
        binding.SendTimeout = New TimeSpan(0, 15, 0)

        Dim endpointAddress As New EndpointAddress(remoteAddress)

        Return New ReportServiceClient(binding, endpointAddress)

    End Function
End Class
In this article