Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ReportingService2010?

I'm trying to deploy a reporting server solution by code using the reporting server web service: http://_Server_Name_/ReportServer/ReportService2010.asmx?wsdl.

Sadly I can't find any examples online. Only some vague information from MSDN.

when publishing through the Business Intelligence Development Studio, it publish the shared data source and then publish the reports. I'm trying to so something similar on C#:

var service = new ReportingService2010();
service.Credentials = new NetworkCredential(username, password, domain);

foreach(var dataSourcePath in GetDataSources()) {
    string name = Path.GetFileNameWithoutExtension(dataSourcePath);
    Byte[] content = GetFileContent(dataSourcePath);
    service.CreateCatalogItem("DataSource", name, parent, true, content, null, out warnings);
}

But the CreateCatalogItem gives me the following SoapException exception:

The input XML does not conform to the schema. XML grammar is described in the API documentation. For XML in reports, refer to Report Definition Language syntax. ---> Microsoft.ReportingServices.Diagnostics.Utilities.InvalidXmlException: The input XML does not conform to the schema. XML grammar is described in the API documentation. For XML in reports, refer to Report Definition Language syntax.

Is there something I'm doing wrong or any other approach I should take?

like image 748
dcarneiro Avatar asked Mar 28 '11 16:03

dcarneiro


2 Answers

I had the same problem. The solution I found is as follows: You are using wrong DataSource file format - like this:

 <?xml version="1.0" encoding="utf-8"?>
 <RptDataSource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="DataSourceXML">
    <ConnectionProperties>
        <Extension>XML</Extension>
        <ConnectString>http://server/_vti_bin/lists.asmx</ConnectString>
        <IntegratedSecurity>true</IntegratedSecurity>
    </ConnectionProperties>
    <DataSourceID></DataSourceID>
</RptDataSource> 

The right one is:

<?xml version="1.0" encoding="utf-8"?>
<DataSourceDefinition xmlns="http://schemas.microsoft.com/sqlserver/reporting/2006/03/reportdatasource">
  <Extension>XML</Extension>
  <ConnectString>http://server/_vti_bin/lists.asmx</ConnectString>
  <CredentialRetrieval>Prompt</CredentialRetrieval>
  <WindowsCredentials>True</WindowsCredentials>
  <Prompt></Prompt>
  <Enabled>True</Enabled>
</DataSourceDefinition>

You can get this definition by downloading DataSource from your Reporting Server.

like image 173
Dmitry Avatar answered Sep 26 '22 19:09

Dmitry


Here's a way to get the XML for each item out of the report server, in a sense a way to "download" the XML definition for any object including a "DataSource" from the Reporting Server (assuming your report server database is ReportServer):

select *, CONVERT(varchar(max),Content) as ContentText
from 
(
      SELECT 
     ItemID,Name,[Type],TypeDescription 
    , CASE 
      WHEN LEFT(Content,3) = 0xEFBBBF 
        THEN CONVERT(varbinary(max),SUBSTRING(Content,4,LEN(Content))) 
      ELSE 
        Content 
      END AS Content 
    from
    (
      SELECT 
         ItemID,Name,[Type] 
       , CASE Type 
          WHEN 2 THEN 'Report' 
          WHEN 5 THEN 'Data Source' 
          WHEN 7 THEN 'Report Part' 
          WHEN 8 THEN 'Shared Dataset' 
          ELSE 'Other' 
         END AS TypeDescription 
       , CONVERT(varbinary(max),Content) AS Content    
       FROM ReportServer.dbo.Catalog 
       WHERE Type IN (2,5,8)
    ) as ItemContentBinaries
) as ItemContentNoBOM

For an SQL data source this is the definition we had:

<?xml version="1.0" encoding="utf-8"?>
<DataSourceDefinition xmlns="http://schemas.microsoft.com/sqlserver/reporting/2006/03/reportdatasource">
  <Extension>SQL</Extension>
  <ConnectString>Data Source=MyDatabaseServer;Initial Catalog=MyDatabase</ConnectString>
  <CredentialRetrieval>Integrated</CredentialRetrieval>
  <Enabled>True</Enabled>
</DataSourceDefinition>

One thing to keep in mind is that we could not find a way to change the .rds files and get it to work with both the reporting IDE and automatic deployment. We are using a .rptproj with Visual Studio 2008 (Visual Studio 2010 can't work with Sql Server 2008 R2 Reporting Server projects). Visual Studio 2008 requires the DataSource files (*.rds files) to be in the old schema format, which won't work with rs.exe and CreateCatalogItem.

If we convert the .rds file to a format that works with CreateCatalogItem, the Sql Server 2008 R2 Reporting Server project gives the following error when trying to open the .rptproj:

Microsoft SQL Server Report Designer The report definition failed to load: There is an error in XML document (2, 2).. Verify the report definition conforms to the correct schema. There is an error in XML document (2, 2). (System.Xml)

<DataSourceDefinition xmlns='http://schemas.microsoft.com/sqlserver/reporting/2006/03/reportdatasource'> was not expected. (wp6bqrt3)
like image 34
Michael Ferrante Avatar answered Sep 24 '22 19:09

Michael Ferrante