Consume web api in SSRS with parameter

◇◆丶佛笑我妖孽 提交于 2019-12-03 00:41:38

Connection String can be a expression. So, you can create a parameter and set your data sourceconnection string to something like that:

="http://some_xyz_url.com/Api/Report/GetReport?id=" & Parameters!ReportParameter1.Value
djangojazz

For an XML Source for the 'Data Source' I have done it with WCF which I would assume is similar to what you are describing if you are wanting to consume a web service for your data you are obtaining and you just want to pass in parameters into the signature of a method call you are making.

Four things when consuming a web service with SSRS:

  1. You need to set your Data Source to use XML (looks like you got that part).
  2. Your web service must be using basic HTTP as it's binding type.
  3. If you are consuming a service the 'Connection String' needs to be the service address. EG for a locally hosted service it would be:

    http: //localhost/Reporting/ReportService.svc
    

    for a service deployed under my default directory with the project named 'Reporting' and a service with the interface of ReportService. I would also test you can get to this service in Visual Studio by trying to hunt for it and ensure it is working. Or if it is discoverable find it with a browser.

  4. Once I have this I need to create a 'DataSet' querying this service correctly. MS has a 'query' xml blob that does this. If you have parameters your service will take it is important to list them in the 'Parameters' node.

    <Query>
    <Method Name="GetStateLike" Namespace="http://tempuri.org/">
    <Parameters>
    <Parameter Name="state"></Parameter>
    </Parameters>
    </Method>
    <SoapAction>
    http://tempuri.org/IReportingService/GetStateLike
    </SoapAction>
    </Query>
    

Most of the problem is how delicate it is to consume. I got it to work but deemed it so fragile I did not want to use it in the end for my problems. More on it here too: How to consume a WCF service with SSRS 2008 R2

After a long try I was no able to solve this , here is what i follow at the end and it works I can not change web api , so I added a wcf service in the solution which was consuming webapi ( just a wrapper ). i know the wcf wrapper is not wise , but it solve the purpose to pass parameters to the webapi.

and then I consume wcf service in my SSRS application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!