Saturday, October 31, 2015

WebService as DataSource in SSRS





In this article, I will show you how to use Web Service as Data Source in SSRS.
1. First of all create one web service in visual studio 2010. In that web service create one Web Method which returns list of strings.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
[WebMethod]
public List<string> getListPlayers()
{
    List<string> list = new List<string>();
    list.Add("ABC");
    list.Add("MNO");
    list.Add("PQR");
    list.Add("XYZ");
    return list;
}

1-WebService as DataSource in SSRS
2. Now publish web service on your IIS. To check whether web service was published successfully or not, paste following URL on your Internet Explorer.
 http://localhost/Service1.asmx
you will see results something like below:
2-WebService as DataSource in SSRS
3. Now open Visual Studio 2010 and open your existing ssrs project or create new project. In that project crate new report named asDemoWebServiceDataSource. Then create a new Data Source. To create a new data source, right click on Data Source in Report Data window and selectAdd Data Source.
A data source properties window opens. In that select Embedded connection and select XML from list of data source.In connection string text box enter following URL :
http://localhost/Service1.asmx?wsdl
3-WebService as DataSource in SSRS
Then click on OK button.
4. Then right click on Datasets in Report Data window and select Add Dataset.
A Dataset Properties window opens. In that select DataSource and enter following xml query into text box of query.  Then click on OK button.
?
1
2
3
4
<Query>
<Method Namespace="http://tempuri.org/" Name="getListPlayers"></Method>
<SoapAction>http://tempuri.org/getListPlayers</SoapAction>
</Query>
4-WebService as DataSource in SSRS
5. Now your report design looks like below :
5-WebService as DataSource in SSRS
6. Now right click on Report Area and go to Insert–>Table. Now select string as Data field in 1st Column and delete rest 2 columns.
so your report design looks like below :
6-WebService as DataSource in SSRS
7. To see the results click on preview tab. Your report should look like below screenshot :
7-WebService as DataSource in SSRS
Congratulations! We successfully completed use of WebService as DataSource in SSRS.