Telerik Reporting R1 2017

How To: Use Windows Forms Report Viewer With REST Service

This topic explains how to setup the Windows Forms Report Viewer to work with Telerik Reporting REST Service

Prerequisites

Configuring the Windows Forms Report Viewer to work with REST Service

  1. To create a form and host the report viewer in it, you can either use the item template, as explained here, or place it yourself through drag-and-drop from the toolbox.

  2. As soon as the report viewer is on your form, select it and locate the ReportEngineConnection property. invoke the UI editor by pressing the ellipsis button. The Report Engine Connection Editor dialog should appear:

    Winforms Connection Editor REST
  3. The Reporting engine combobox provides the following options:

    • Embedded - the reports will be processed and rendered at the local machine that hosts the viewer. This is the default mode in order to preserve backwards compatibility.

    • REST Service - the reports will be processed at the machine that hosts configured and running REST Service instance.

    • Report Server - the reports will be processed and rendered at the machine that hosts configured and running Telerik Report Server instance.

    Select REST Service.

  4. In URL textbox enter the address and port (if needed) of the machine that hosts the REST Service instance. Note that the /api/reports part is already added so you need to prefix it with the service address.

  5. Check the Use default credentials checkbox if you need the default credentials to be sent with the requests by the HTTP client handler that is used internally to communicate with the REST service.

  6. Click OK when ready. The dialog will close and the resulting connection string will be populated as a value of the ReportEngineConnection property.

  7. Locate the ReportSource property. Invoke the UI editor by pressing the ellipsis button. The Report Source Editor dialog should appear:

    Winforms Report Source Editor URL
    Important note Important

    When the ReportEngineConnection property has Engine set to RestService, the viewer will serialize the report source identifier property (URI for UriReportSource, TypeName for TypeReportSource, ReportDocument for InstanceReportSource and XML for XmlReportSource) and send it to the service resolver.

    The REST service will use the ReportResolver instances included in its ReportServiceConfiguration to resolve the report by the provided identifier. However, the REST service's default implementation includes only ReportFileResolver and ReportTypeResolver, so you need to provide a CustomReportResolver if you use another type of ReportSource.

  8. In this scenario we will use a UriReportSource. Select the URL or file radio button. Enter the path and the name of the report you want to display.

    If needed, you can setup the report source parameters using the dialog, invoked by pressing the Edit Parameters button.

  9. Click OK when ready. The dialog will close and the resulting report source will be populated as a value of the ReportSource property.

  10. Build and run your application. If your settings are configured correctly, you should see the report displayed in the report viewer of your WinForms application. If not, check the Troubleshooting section below.

Troubleshooting

The following table shows the most common reasons for failure when using the Telerik Reporting REST Service. It is strongly recommended to use a tool like Fiddler or any other web debugger when investigating such a problem.

Problem

Cause

The viewer displays the message: A problem occurred while registering client.

Check if the REST service is active and running - the easiest way is to make a request for the available document formats, as explained here.

The viewer displays the message: System.OperationCanceledException: {ReportName} report cannot be resolved.

Make sure the URL or type name specified in the report source property is valid and can be resolved by the REST service.

The viewer displays the message: System.Net.WebException: The remote name could not be resolved: {name}

Make sure that the address specified in the connection string exists and represents a valid and running REST service instance.

See Also