How to dynamically set the Service Url field of a Web Service Data Source

13 posts, 0 answers
  1. Edward
    Edward avatar
    65 posts
    Member since:
    Oct 2018

    Posted 18 Oct 2018 Link to this post

    Have a Web Service Data Source in the Report Designer.  Want to set the Service Url field dynamically based on report parameter passed in.  Is this possible?  That field doesn't have an Expression option.  It's just a text field...

     

  2. Edward
    Edward avatar
    65 posts
    Member since:
    Oct 2018

    Posted 19 Oct 2018 Link to this post

    Was going about this the wrong way initially- using the Report Designer... instead of using the Report Library and defining my own reports with access to underlying C# classes and api's.  This would give me better controls and accessibility. 
  3. Silviya
    Admin
    Silviya avatar
    417 posts

    Posted 23 Oct 2018 Link to this post

    Hello Edward,

    I suggest to provide the Service Url as an inline parameter, i.e Service Url property of the WebServiceDataSource can be set as an inline parameter @Url, and then the value of @Url can be provided as an Expression (i.e. taken from a Report Parameter) so that its value to be evaluated run time. Please refer to this screen shot - https://www.screencast.com/t/jtcgJ2EAK

    Regards,
    Silviya
    Progress 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
  4. Marius
    Marius avatar
    1 posts
    Member since:
    Oct 2019

    Posted 18 Oct 2019 in reply to Silviya Link to this post

    Hi,

    If you see in your screenshot it says "Invalid URI: The hostname could not be parsed" .. It should use the Design-time Value.

    This aside, exactly the same message I get in the web viewer:

    An error has occurred while processing Table 'table1':
    Invalid URI: The hostname could not be parsed

     

  5. Todor
    Admin
    Todor avatar
    452 posts

    Posted 22 Oct 2019 Link to this post

    Hi Marius,

    Which version do you use? There is a known problem with our latest official release 13.2.19.918 related to WebServiceDataSource. It has been fixed in the Internal Build 13.2.19.1004 - 'WebServiceDataSource - Parameters are not correctly evaluated during processing'. You may upgrade to the Latest Internal Build.

    Regards,
    Todor
    Progress 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
  6. Tally
    Tally avatar
    6 posts
    Member since:
    Apr 2019

    Posted 28 Oct 2019 in reply to Silviya Link to this post

    I am trying to implement the inline url, and have 2 problems:

    1. It does not work

    2.I need to concat the controller's method name to the url, different to each service data source.

    when I see the service url it is written as "@url" (attached picture of the parameters in the report, and the result on the server)

    angular client side code:

    let rs = {
          report: this.reportName,
          authenticationToken: token,
          parametersAreaVisible: false,
          parameters: {
            Url:'http://localhost:52913/api/alarms/'
          }
        } as unknown as JSON;

    When I want to concat Url with method name do I do it on the parameters form like:

    value= Parameters.Url,Value+"myMethodName

    or on the ServiceUrl property like : @url myMethodName

    maybe i need some brackets?

    TX

    Tally

  7. Tally
    Tally avatar
    6 posts
    Member since:
    Apr 2019

    Posted 28 Oct 2019 in reply to Tally Link to this post

    OK I got it to work:

    I had my own code problems, to make the problems above.

    1. Add a parameter to the whole report, to represent the Url, lets call it Url

    2. On the client side:angular client side code:
    let rs = {
          report: this.reportName,
          authenticationToken: token,
          parametersAreaVisible: false,
          parameters: {
            Url:'http://localhost:52913/api/alarms/'
          }
        } as unknown as JSON;

    3.add an inline parameter to each web service data source. Name: @Url Type: inline Value: = Parameters.Url.Value +'myMethodName'

    4.set the service url of this web service data source to @Url

     

    Hope I have helped.

     

  8. Thanh
    Thanh avatar
    4 posts
    Member since:
    Oct 2019

    Posted 25 Nov 2019 in reply to Todor Link to this post

    I'm using Telerik Reporting R3 2019 but still error: "Invalid URI: The hostname could not be parsed"

     

  9. Todor
    Admin
    Todor avatar
    452 posts

    Posted 27 Nov 2019 Link to this post

    Hello Thanh,

    The problem you experience may be due to a known issue with version 13.2.19.918. The problem is fixed in the Service Pack - version 13.2.19.1030 - Fixed-Web Service Data Source-Parameters are not correctly evaluated during processing. Test to upgrade to our latest version and check whether the problem will be fixed.

    Regards,
    Todor
    Progress 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
  10. Thanh
    Thanh avatar
    4 posts
    Member since:
    Oct 2019

    Posted 28 Nov 2019 in reply to Todor Link to this post

    Thank you!
  11. Shawn
    Shawn avatar
    44 posts
    Member since:
    Jul 2016

    Posted 23 Jan Link to this post

    I have a slightly different scenario, but still along the same lines as this.

    Our reports use WebServiceDataSource with the Service URL defined as @Url and at run-time this value set using the DataSource parameter passed into the report form our web page.  (i.e. = Parameters.DataSource.Value).  This all works fine.  The DataSource value would be:  

    https://<domain>/api/Reports/v1.0/Security

     

    Our reports also include parameters, one of which is a list of customer sites.  So I created another WebServiceDataSourcecalled dsSitesParam and set the Service URL to @Url1.  The API would be similar to the DataSource value except the 'Security' text would be replaced with 'Sites', so at run-time we are using the same DataSource paramater but using the Replace function to change the 'Security' to 'Site'.  (i.e. = Replace(Parameters.DataSource.Value,"Security","Sites")

    At design time when using the hard-coded path to the Sites api and can download the site just fine.  See screenshot dsSitesParam.

     

    The reports also have a Sites parameter.  When using a CSV Data Source for this parameter, it works fine.  When I set it to use the dsSitesParam data source, the report fails to load with the following error:

     

    Invalid URI: Hostname could not be parsed

     

    Should I be able to use the Replace function of the DataSource value to change it to the correct API to be used for getting the list of sites?

     

  12. Todor
    Admin
    Todor avatar
    452 posts

    Posted 28 Jan Link to this post

    Hi Shawn,

    I tested the described scenario as I understood it and can confirm that you may use the Replace function when setting the WebServiceDataSource Url through an Expression. I have attached a demo report with the Web API project exposing the data services. The data services run on 'http://localhost:50160/api/data' and 'http://localhost:50160/api/site'. The parameter 'Parameter1' has AvailableValues coming from 'webServiceDataSource2', which Url is set with:

    = Replace(Parameters.Url.Value,"data","site")

    I suspect that there is something inaccurate in the final Url. You may use Fiddler to access the exact requests to check this.

    Regards,
    Todor
    Progress 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
  13. Shawn
    Shawn avatar
    44 posts
    Member since:
    Jul 2016

    Posted 28 Jan in reply to Todor Link to this post

    Todor,

    Thank you for the reply.  After some further testing and moving things around it came down to the order in which the parameters were being defined.  I was trying the process the 'Sites' parameter which was using the 'Replace' function on a parameter ('DataSource') that was not yet defined.  So I moved the 'Sites' parameter down the list so that it was being defined after the 'DataSource' parameter.

    Working fine now.

    Regards,

    Shawn

Back to Top