Wednesday, February 15, 2012

export report server contents/items to xml file

how can I output the contents or my report server to an xml file? I
assume I would use some variation of ListChildren and the WriteXml
method.I was able to accomplish this using the following code:
Dim impersonationContext As
System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As
System.Security.Principal.WindowsIdentity
currentWindowsIdentity = CType(User.Identity,
System.Security.Principal.WindowsIdentity)
impersonationContext = currentWindowsIdentity.Impersonate()
Dim rs As New ReportingService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim items As CatalogItem() = Nothing
' Retrieve a list of all items from the report server database.
Try
items = rs.ListChildren("/", True)
Catch ex As Exception
response.write(ex.Message)
End Try
' Serialize the contents as an XML document and write the
contents to a file.
Try
Dim fs As New FileStream("C:\CatalogItems.xml",
FileMode.Create)
Dim writer As New XmlTextWriter(fs, Encoding.Unicode)
Dim serializer As New XmlSerializer(GetType(CatalogItem()))
serializer.Serialize(writer, items)
response.write("Contents successfully written to a file.")
Catch ex As Exception
response.write(ex.Message)
End Try
Stephen wrote:
> how can I output the contents or my report server to an xml file? I
> assume I would use some variation of ListChildren and the WriteXml
> method.

No comments:

Post a Comment