New to Telerik Reporting? Download free 30-day trial

Using the Windows Forms Report Viewer With a 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 in the article How to Add report viewer to a Windows Forms .NET Framework project, 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:

    Image of the Windows Forms Connection Editor window, showing the REST Service option.

  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. In the Document timeout textbox you can change the timeout for rendering a document, the default is 100 seconds.
  7. Uncheck the Keep client alive checkbox if you want the client session to expire.
  8. Click OK when ready. The dialog will close and the resulting connection string will be populated as a value of the ReportEngineConnection property.
  9. Locate the ReportSource property. Invoke the UI editor by pressing the ellipsis button. The Report Source Editor dialog should appear:

    Image of the Windows Forms Report Source Editor window, showing a valid report URL.

    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 ReportSourceResolver instances included in its ReportServiceConfiguration to resolve the report by the provided identifier. However, the REST service 's default implementation includes only UriReportSourceResolver and TypeReportSourceResolver, so you need to provide a Custom Report Source Resolver if you use another type of ReportSource.

  10. 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.

  11. Click OK when ready. The dialog will close and the resulting report source will be populated as a value of the ReportSource property.
  12. 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 in the article How to Add Telerik Reporting REST Web API to Web Application.
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

In this article