Progress® Telerik® Reporting R3 2017

How To: Use WPF Report Viewer With REST Service

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

Prerequisites

Configuring the WPF 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 dialog should appear:

    wpf-connection-editor-rest-service
  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:

    Wpf Report Source Editor
    Important note Important

    When the ReportEngineConnection property has Engine set to RestService or ReportServer, 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 UriReportSource entry. Confirm by clicking OK.

  9. Expand the ReportSource node in Properties window. In the provided Uri textbox enter the category and the name of the report you want to display using the following format: {Category}/{ReportName}, as shown below:

    Wpf Set Uri Report Source Property Grid
  10. Click OK when ready. The dialog will close and the resulting report source will be populated as a value of the ReportSource property.

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

Important note Important

When setting ReportEngineConnection with code, make sure you call the RefreshReport() method or set the ReportSource property afterwards, so the connection's new value will be respected.

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