locked
Upload PDF files to SRS Site programmatically RRS feed

  • Question

  • All,

    I know how to publish reports to SRS using rs.exe but I cannot find a way to just upload a bunch of files using a scripts.

    Any examples using VBS, batch, or VB.NET would be helpful.

    Thanks,

     

    Rafael

    Monday, July 12, 2010 3:48 PM

Answers

  • Hi Rafael,

    In order to upload files to a Report Server programmatically , we can use the CreateResource method in the Reporting Services web services.

    Public Sub UploadResource()
     Dim definition As [Byte]() = Nothing
     Try
      Dim stream As FileStream = File.OpenRead("<file path>")
      definition = New [Byte](stream.Length) {}
      stream.Read(definition, 0, CInt(stream.Length))
      stream.Close()
     Catch e As IOException
      Console.WriteLine(e.Message)
     End Try
     Try
      rs.CreateResource("Book for SSRS", "/", False, definition , "application/pdf",Nothing)
       Console.WriteLine("Resource: {0} published successfully with no warnings", "Book for SSRS")
     Catch e As Exception
      Console.WriteLine(e.Message)
     End Try
    End Sub 
    

    For more information about CreateResource, please see:
    http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.createresource.aspx

    Please feel free to ask, if you have any more questions.

    Thanks,
    Jin Chen


    Jin Chen - MSFT
    • Marked as answer by RafaelFilpo Thursday, July 15, 2010 2:29 PM
    • Unmarked as answer by RafaelFilpo Thursday, July 15, 2010 2:29 PM
    • Marked as answer by RafaelFilpo Thursday, July 15, 2010 2:30 PM
    Wednesday, July 14, 2010 7:32 AM
  • All I feel silly but I found out what the issue was: I was adding a service reference and not a web reference. VS 2010 does this a bit differently so it had me scratching my head for a while.

    Thanks for your support.

    Rafael

    • Marked as answer by RafaelFilpo Thursday, July 15, 2010 2:32 PM
    Thursday, July 15, 2010 2:32 PM

All replies

  • Hi Rafael,

    In order to upload files to a Report Server programmatically , we can use the CreateResource method in the Reporting Services web services.

    Public Sub UploadResource()
     Dim definition As [Byte]() = Nothing
     Try
      Dim stream As FileStream = File.OpenRead("<file path>")
      definition = New [Byte](stream.Length) {}
      stream.Read(definition, 0, CInt(stream.Length))
      stream.Close()
     Catch e As IOException
      Console.WriteLine(e.Message)
     End Try
     Try
      rs.CreateResource("Book for SSRS", "/", False, definition , "application/pdf",Nothing)
       Console.WriteLine("Resource: {0} published successfully with no warnings", "Book for SSRS")
     Catch e As Exception
      Console.WriteLine(e.Message)
     End Try
    End Sub 
    

    For more information about CreateResource, please see:
    http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.createresource.aspx

    Please feel free to ask, if you have any more questions.

    Thanks,
    Jin Chen


    Jin Chen - MSFT
    • Marked as answer by RafaelFilpo Thursday, July 15, 2010 2:29 PM
    • Unmarked as answer by RafaelFilpo Thursday, July 15, 2010 2:29 PM
    • Marked as answer by RafaelFilpo Thursday, July 15, 2010 2:30 PM
    Wednesday, July 14, 2010 7:32 AM
  • Thanks for the reply Jin but I get a message indicating that 'rs' is not declared on rs.CreateResource.

    I have a web reference to http://localhost/reportserver/reportexecution2005.asmx?wsdl but not sure what elese is missing.

    Thanks,

    Rafael

    Wednesday, July 14, 2010 1:37 PM
  • Just add

    ReportingService rs=new ReportingService();


    Nanda - Misys Software Solutions,Bangalore
    Wednesday, July 14, 2010 5:19 PM
  • I figured as much but it does not work. It has a red line at the end of ReportingServices and when I click on it, it suggests .Job, .Task, and .Role (Change ReportingServices to ReportingServices.Role).

    Tried both VS 2010 and VS2008 however both run on Windows Server 2008.  My SSRS is running on SQL 2005 with SP3.

    • Edited by RafaelFilpo Wednesday, July 14, 2010 6:28 PM more info
    Wednesday, July 14, 2010 6:27 PM
  • Hi Rafael,

    The CreateResource method is in the ReportService2005 endpoint, not ReportExecution2005.

    So, please use the web reference http://localhost/reportserver/ReportService2005.asmx?wsdl  instead of http://localhost/reportserver/reportexecution2005.asmx?wsdl.

    Thanks,
    Jin Chen


    Jin Chen - MSFT
    Thursday, July 15, 2010 4:17 AM
  • I have and now it tells me type expected and it has the same options listed above ( .Job, .Task, and .Role). Really strange.  Could it be an option I don't have install for SRS or Visual Studio?

    • Edited by RafaelFilpo Thursday, July 15, 2010 11:07 AM na
    Thursday, July 15, 2010 11:07 AM
  • Hi Rafael,

    Could you please post the detailed error message?

    Since we add a reference to the Reporting Services web service, we don't need to install Reporting Services on the Dev machine.

    Thanks,
    Jin Chen


    Jin Chen - MSFT
    • Marked as answer by RafaelFilpo Thursday, July 15, 2010 2:29 PM
    • Unmarked as answer by RafaelFilpo Thursday, July 15, 2010 2:29 PM
    Thursday, July 15, 2010 12:31 PM
  • All I feel silly but I found out what the issue was: I was adding a service reference and not a web reference. VS 2010 does this a bit differently so it had me scratching my head for a while.

    Thanks for your support.

    Rafael

    • Marked as answer by RafaelFilpo Thursday, July 15, 2010 2:32 PM
    Thursday, July 15, 2010 2:32 PM