Connecting to SSRS Reporting Services via C#

  • To standardise our SSRS deployments with everything else we deploy, I am trying to create a small C# class that just deploys a report via a SSRS Web Service.

    Initially, it looks quite simple using the ReportingService2005.CreateReport() method and the sample supplied in that method documentation.

    In a nutshell, we generate a proxy class in visual studio using the http://MyDevServerName/reportserver/reportservice2005.asmx and then create an instance of that class and use the associated CreateReport() method.

    ReportingServices2005 rs = new ReportingServices2005();

    bla bla bla;

    rs.CreateReport(...);

    So far so good...

    ... Until I realised I want to specify my server name somewhere!

    Surely, there must be a way to point at a different server at runtime but I can't see a constructor taking any argument...

    Could someone tell me the bit I am missing, please?

    Thanks :doze:

  • I forgot to specify that I am using Visual Studio 2005 for this...

  • You could run rs.exe (a binary that does reporting services deployments) through Reflector (a program that gives you a little look inside .NET binaries like that) and have a look at how it initialises everything. Judging from http://msdn.microsoft.com/en-us/library/aa225885(v=sql.80).aspx it looks like they extend the ReportingService class which gives them access to a private Url variable 🙂

    What I've done before as a quick hack (until I learn how to do it properly) is include rs.exe as an assembly and use it like this for the management and execution side:

    Imports Microsoft.SqlServer.ReportingServices2005

    '

    rs_m = New ReportingService2005()

    __ProxyHelper.InitSoapProxy(rs_m, serverUrl & "/ReportService2005.asmx", username, password, domain, timeout)

    rs_e = New Execution.ReportExecutionService()

    __ProxyHelper.InitSoapProxy(rs_e, serverUrl & "/ReportExecution2005.asmx", username, password, domain, timeout)

    __ProxyHelper being a class inside rs.exe (I think; I did this a long time ago).

  • Actually, for some reason, I did not spot that the variable is stored inside App.config but that still leaves me the problem of trying to overrule this on the fly because I want to set this URI dynamically.

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

    <configSections>

    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >

    <section name="WinReportServicesTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

    </sectionGroup>

    </configSections>

    <applicationSettings>

    <WinReportServicesTest.Properties.Settings>

    <setting name="WinReportServicesTest_MyWebReference_ReportingService2005"

    serializeAs="String">

    <value>http://localhost/ReportServer$sql2005/ReportService2005.asmx</value&gt;

    </setting>

    </WinReportServicesTest.Properties.Settings>

    </applicationSettings>

    </configuration>

    Any idea how I can get the ReportingService2005 proxy class to initiate from my code rather than App.config?

  • Oops!

    It looks like this object exposes a Url property!

    I can't believe I missed that too...

    To my defence, my Help seems broken and I could not see these properties...

    Poor excuse I know... :blush:

    Thanks for your help anyway

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply