Bug in SSRS SetItemDataSources Web Service Method
Bug: An existing SSRS 2005 data source at the root directory cannot be used by the SSRS SetItemDataSource web method. Steps to reproduce: 1. On the machine running SSRS 2005, create a folder named Reports and upload an RDL file named "Existing.rdl" into that directory. For clarity the SSRS path to this report is /Reports 2. Set up a valid data source at the root directory (For illustrative purposes we'll name it DS). 3. Set up a web reference to a SQL Server Reporting Web Services 2005. e.g. http://localhost/reportserver/reportservice2005.asmx 3. Try to set the DS data source to the "Existing" report by calling the SetItemDataSource web method. C# Code Excerpt: ... try{ ReportingService2005 reprtSrvc = new ReportingService2005(); DataSource[] dsarray; string reportName = "Existing" string _selectedFolder = "/Reports/" DataSourceReference reference = new DataSourceReference(); DataSource ds = new DataSource(); dsarray = new DataSource[1]; reference.Reference = "/"; ds.Item = reference; ds.Name = "DS"; dsarray[0] = ds; //Exception thown ... _reprtSrvc.SetItemDataSources("/" + _selectedFolder + reportName , dsarray); } catch (SoapException ex) { //Exception Message.displayMessage(ex.Detail["Message"].InnerXml, MessageType.Error); } ... Exception details... ex {"System.Web.Services.Protocols.SoapException: The operation you are attempting on item \"\" is not allowed for this item type. ---> Microsoft.ReportingServices.Diagnostics.Utilities.WrongItemTypeException: The operation you are attempting on item \"\" is not allowed for this item type.\n at Microsoft.ReportingServices.Library.SetItemDataSourcesAction.ResolveNewDataSources(DataSourceInfoCollection newDataSources, Boolean forModel)\n at Microsoft.ReportingServices.Library.SetItemDataSourcesAction.SetReportDataSources(CatalogItem item, DataSource[] dataSources)\n at Microsoft.ReportingServices.Library.SetItemDataSourcesAction.PerformActionNow()\n at Microsoft.ReportingServices.Library.RSSoapAction`1.Execute()\n at Microsoft.ReportingServices.WebServer.ReportingService2005Impl.SetItemDataSources(String Item, DataSource[] DataSources)\n --- End of inner exception stack trace ---\n at Microsoft.ReportingServices.WebServer.ReportingService2005Impl.SetItemDataSources(String Item, DataSource[] DataSources)\n at Microsoft.ReportingServices.WebServer.ReportingService2005.SetItemDataSources(String Item, DataSource[] DataSources)"} System.Web.Services.Protocols.SoapException
December 19th, 2007 6:44pm

I hanged your code like that : ReportingService2005 reprtSrvc = new ReportingService2005(); reprtSrvc .Credentials = System.Net.CredentialCache.DefaultCredentials; reprtSrvc .Url = txtFolder.Text + "reportserver/reportservice2005.asmx"; /* Get sub directories */ DataSource[] dsarray; string reportName = "Example" string _selectedFolder = "/Reports/"; DataSourceReference reference = new DataSourceReference(); DataSource ds = new DataSource(); dsarray = new DataSource[1]; string DSName= "DS" reference.Reference = "/Data Sources/"+DSName; ds.Item = reference; dsarray[0] = ds; reprtSrvc .SetItemDataSources( _selectedFolder +reportName , dsarray); and it's working correct.
Free Windows Admin Tool Kit Click here and download it now
September 25th, 2008 10:56am

I think I tried setting the data source reference, this was back in December. I will have to see if this works; I will post later today.
September 25th, 2008 5:19pm

For clarity for others who may want to use this, I've condensed that confusing code: DataSource[] dsarray = new DataSource[1];dsarray[0] = new DataSource();dsarray[0].Item = new DataSourceReference();dsarray[0].Item.Reference = "/Data Sources/DS";reprtSrvc .SetItemDataSources("/Reports/Example", dsarray); It might be best in a particular application to declare variables and such as above, but these 5 lines make very clear what's going on in a way that the above code doesn't.
Free Windows Admin Tool Kit Click here and download it now
October 15th, 2008 9:00pm

use the following code! DataSourceReference dsr = new DataSourceReference(); dsr.Reference = dataSourcePath + "/" + dataSourceName; DataSource[] dsarray = rs.GetItemDataSources(serverPath + "/" + reportName); DataSource ds = new DataSource(); ds = dsarray[0]; ds.Item = (DataSourceReference)dsr; rs.SetItemDataSources(serverPath + "/" + reportName, dsarray); I hope this 'll resolve the problem. regards, Noman Rao
May 13th, 2012 3:58am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics