How to use SSRS Web Service from Java

 

  1. Import the reporting service wsdl using wsimport tool which is available in JDK starting from v1.6:
    wsimport.exe http://<server>/reportserver/reportService2005.asmx?wsdl -s  -extension
  2. Copy the resulting package to your java project. Amon other things, it will contain the ReportingService2005 class and the ReportingService2005Soap interface which are the main point of your interest.

  3. Sample code which lists all the items deployed to Reporting Server:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package testSSRS;
 
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfCatalogItem;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.CatalogItem;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportingService2005;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportingService2005Soap;
 
public class mainClass {
 
    public static void main(String[] args) {
 
        ReportingService2005 srv = new ReportingService2005();
        ReportingService2005Soap srvs = srv.getReportingService2005Soap();
 
        ArrayOfCatalogItem arr = srvs.listChildren("/", true);
 
        for (CatalogItem ci : arr.getCatalogItem())
        {
            System.out.println(ci.getPath() + "/" + ci.getName());
        }
    }
 
}
package testSSRS;

import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfCatalogItem;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.CatalogItem;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportingService2005;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportingService2005Soap;

public class mainClass {

	public static void main(String[] args) {

		ReportingService2005 srv = new ReportingService2005();
		ReportingService2005Soap srvs = srv.getReportingService2005Soap();

		ArrayOfCatalogItem arr = srvs.listChildren("/", true);

		for (CatalogItem ci : arr.getCatalogItem())
		{
			System.out.println(ci.getPath() + "/" + ci.getName());
		}
	}

}

Same will work for Reporting Services 2010, too, just change the URI of the webservice when importing the wsdl and ensure the use of right names of the packages, classes and interfaces:

wsimport.exe http://<server>/reportserver/reportService2010.asmx?wsdl -s  -extension

and ensure the right names of the packages, classes and interfaces:

1
2
3
4
5
import com.microsoft.schemas.sqlserver.reporting._2010._03._01.reportserver.ReportingService2010;
import com.microsoft.schemas.sqlserver.reporting._2010._03._01.reportserver.ReportingService2010Soap;
...
        ReportingService2010 srv = new ReportingService2010();
...
import com.microsoft.schemas.sqlserver.reporting._2010._03._01.reportserver.ReportingService2010;
import com.microsoft.schemas.sqlserver.reporting._2010._03._01.reportserver.ReportingService2010Soap;
...
		ReportingService2010 srv = new ReportingService2010();
...

 

Detailed information about the SSRS Web Service classes can be found on MSDN:
ReportingService2005 and ReportingService2010.
 
Good Luck!
 

Leave a comment

Your email address will not be published. Required fields are marked *