Hello,
I have a problem with this line :
_report = (Report)serializer.Deserialize(stream);
while trying to reproduce this : http://msdn.microsoft.com/en-us/library/aa337430.aspx (Load a Report Definition from the Report Server)
There is an error in XML document (2, 2) : <Report xmlns='http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition'> unexpected.
So I added :
XmlRootAttribute xRoot = new XmlRootAttribute();xRoot.ElementName = "Report";
xRoot.Namespace = "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition";
xRoot.IsNullable = true;
but now I have :
The specified type is abstract : name='Report', namespace='http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition', for <Report xmlns='http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition'>.
(translated from french)
Many thanks in advance !
Alain
My code :
ReportingService2010 _reportService; _reportService = new ReportingService2010(); _reportService.Credentials = new System.Net.NetworkCredential("Emeline", "2711"); _reportService.Url ="http://localhost:8080/ReportServer/ReportService2010.asmx"; string reportPath = "/report1"; // Retrieve the report defintion // from the report server Report _report; byte[] bytes = _reportService.GetItemDefinition(reportPath); ReportService2010.Warning[] warnings; //Create new report from report definition obtained in previous step and set datasource. // _reportService.CreateCatalogItem("Report", "CopiedReport", "/", false, bytes, null, out warnings); if (bytes != null) { XmlRootAttribute xRoot = new XmlRootAttribute(); xRoot.ElementName = "Report"; xRoot.Namespace = "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"; xRoot.IsNullable = true; XmlSerializer serializer = new XmlSerializer(typeof(Report),xRoot); // Load the report bytes into a memory stream using (MemoryStream stream = new MemoryStream(bytes)) { // Deserialize the report stream to an // instance of the Report class XmlReader xmlReader = XmlReader.Create(stream); XmlWriter xmlWriter; using (xmlWriter = XmlWriter.Create("tmprep.xml")) { xmlWriter.WriteNode(xmlReader, false); } Response.Write("ready to deserialize"); stream.Position = 0; _report = (Report)serializer.Deserialize(stream); xmlReader.Close(); } }Versions : VS2012 / SQL2012 / REPORTBUILDER 3