WPF ReportViewer consuming REST Services

7 posts, 1 answers
  1. Matthias
    Matthias avatar
    6 posts
    Member since:
    Jan 2016

    Posted 02 Jun Link to this post

    Hi,

    according to the release history of Telerik Reporting R2 2016 the WPF ReportViewer now supports showing reports from Telerik Reporting REST Service. So I implemented a web application as described in the docs (http://docs.telerik.com/reporting/telerik-reporting-rest-host-http-service-using-web-hosting) and setup a WPF client application with the help of these articles:
    http://docs.telerik.com/reporting/wpf-report-viewer-howto-use-it-with-reportserver
    http://docs.telerik.com/reporting/report-engine-connectionstring#rest-service-engine

    The XAML of the client now looks as follows:
    1.<tr:ReportViewer x:Name="ReportViewer1" HorizontalAlignment="Stretch" ReportEngineConnection="engine=RestService;uri=http://localhost:19021/api/reports">
    2.    <tr:ReportViewer.ReportSource>
    3.        <telerikReporting:UriReportSource Uri="TestReport.trdp" />
    4.    </tr:ReportViewer.ReportSource>
    5.</tr:ReportViewer>


    I also tried setting the Uri-Property of the UriReportSource to the full Uri or leaving out the trdp extension but the viewer only contains this error message:

    Attempt by method 'Telerik.Reporting.Services.HttpClient.HttpRequestHelper.GetResponseFromPost(System.Net.Http.HttpResponseMessage)' to access method 'Telerik.Reporting.Services.HttpClient.HttpRequestHelper.GetResponseFromPost<T>(System.Net.Http.HttpResponseMessage, System.Collections.Generic.IEnumerable`1<System.Net.Http.Formatting.MediaTypeFormatter>)' failed.

    Because I couldn't find much documentation about using the REST services with the WPF ReportViewer I could use some help.

    Thanks
    Matthias
  2. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 07 Jun Link to this post

    Hello Matthias,

    It looks like an issue when you use the latest versions of the WebAPI Clients libraries Nuget package. Binding redirects seem to not work. Using the older versions should avoid the issue.

    The question is forwarded to our development team and I will update this thread when there is news.


    For anyone interested,the WPF ReportViewer can be connected to Telerik Report Server or a Reporting REST Service by address - How To: Use WPF Report Viewer with Report Server. details how to create the connection are available in ReportEngineConnection Property.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. Answer
    Stef
    Admin
    Stef avatar
    3047 posts

    Posted 07 Jun Link to this post

    Hello,

    It appears the WPF ReportViewer is designed to work only with the version of Microsoft.AspNet.WebApi.Client suitable for .NET4, in order to avoid API changes required by newer versions dependent on .NET4.5.

    Please uninstall the added Nuget packages, and install this one via Package Manager Console.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Matthias
    Matthias avatar
    6 posts
    Member since:
    Jan 2016

    Posted 14 Jun Link to this post

    Hello Stef,

    thanks. That worked.

    But now I got another problem connecting to my existing web api server component using windows authentication.

    In my WPF application where I consume the web api I connect using a HttpClient using this piece of code:

    1.HttpClientHandler authHandler = new HttpClientHandler()
    2.{
    3.    Credentials = CredentialCache.DefaultNetworkCredentials
    4.};
    5.var httpClient = new HttpClient(authHandler);

    How can I tell the WPF report viewer to use windows authentication?

  6. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 15 Jun Link to this post

    Hi Matthias,

    On connecting the WPF ReportViewer, you can submit credentials to the connected Reporting REST service (of a custom application or of a Telerik Report Server). The connection is specified through the viewer's ReportEngineConnection property. Please check the options of the connection in the linked article.

    The connected Telerik Report Server can be configured to work with ADFS - Configuring Report Server to be used with external authentication provider.
    then you can send user/pass on configuring the viewer's ReportengineConnection.


    The connected custom application with Reporting REST service can be configured to accept authorization tokens and others. the Reporting REST WebAPI service is a WebAPI controller which methods can be overridden to include attributes and custom code for authorizing the access to resources.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Matthias
    Matthias avatar
    6 posts
    Member since:
    Jan 2016

    Posted 16 Jun in reply to Stef Link to this post

    Hi Stef,

    I know how to configure the WebAPI and already did. The problem I'm facing is, that I don't know how to tell the WPF Report Viewer to send the windows credentials of the current windows account (not the username/password).

    My client application is already talking to the other components of my WebAPI-App using the code snippet I posted earlier. I couldn't find any hint, neither in the docs (ReportEngineConnection only supports user/pass or token) nor in the reporting source code.

    The only thing I can think of, is to override the instantiation of the HttpClient inside the WPF ReportViewer. But how can I do that?

    Thanks
    Matthias

  8. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 21 Jun Link to this post

    Hi Matthias,

    Apologies for the misunderstanding.

    After forwarding the question to our development team, It appears we create the HttpClient internally and only tokens can be submitted by the client.

    Please feel free to log a feature request for extending the authentication mechanism to allow Windows Authentication from viewers integrated with a Reporting REST service or Telerik Report Server.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner