12

I have:

private readonly ReportingService2010 _rs = new ReportingService2010();

Error:

The type or namespace name 'ReportingService2010' could not be found (are you missing a using directive or an assembly reference?)

I setup a reference to the SSRS service. The reference does not give me access to ReportingService2010 as I expect. The closest thing is:

MySsrsServiceNamespace.ReportingService2010SoapClient

How am I supposed to use the ReportingService2010 class? MSDN lists this class vaguely.

Please note I tried using ReportingService2010SoapClient. This class does not match the documentation for ReportingService2010. For example, ListChildren() only accepts 4 parameters and the Url property does not exist.

P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348

4 Answers4

41

Just ran into the exact same issue. ReportingService2010SoapClient class was available, but the ReportingService2010 class was not. Was driving me nuts. I had added it as a "Service References", but you have to add it as a "Web References", like so:

  1. Delete your old Service Reference

  2. Right click on References. The "Add Service Reference" dialog comes up.

  3. Do not enter the WSDL URL now, instead: Click on the "Advanced" button at the bottom left.

  4. The "Service Reference Settings" dialog comes up.

  5. At the bottom left, click the "Add Web Reference" button.

  6. Now enter the URL for the WSDL. (for me that was servername/ReportServer/ReportService2010.asmx)

  7. Click the small arrow on the right, it will take its sweet time to load.

  8. Name the web reference, I used "ReportingService2010WebReference", but ReportingService2010" probably works just as well.

  9. Click "Add Reference"

  10. In your code, update your using statements to "using .ReportingService2010WebReference (or whatever name you picked)

Code:

private MySol.ReportService2010WebReference.ReportingService2010 rsClient;

rsClient = new ReportingService2010();
rsClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

CatalogItem[] items = null;

items = rsClient.ListChildren("/", false);

foreach (var item in items)
{
    tr.ErrorMessage += (item.Path + " " + item.CreatedBy);
}

Worked on the first try. Web.config file wasn't touched.

TomEberhard
  • 907
  • 10
  • 11
  • He has my vote. Thanks for this. The only issue I had was that when I added the web reference my project no longer could properly use the System.ServiceProcess library. For some reason changing the framework version to something else then back again fixed it. – Christopher Townsend Feb 25 '15 at 09:46
  • This way is reasonable. I use this and add web references. Thanks bro. – tonymiao Oct 12 '15 at 23:02
  • 1
    I wish there were better docs available on doing it the MS-approved way in WCF, i.e. as a service reference rather than a web reference. The reason I feel this way is web references are the older technology pushed aside in favor of WCF service references, and one major limitation of the former is the default access modifier of `public` on proxy classes (see my SO question [here](http://stackoverflow.com/questions/37303550/add-a-web-reference-to-a-project-but-make-the-auto-generated-proxy-classes-inter)) – rory.ap May 18 '16 at 15:48
  • finally!! this simple solution should be included in MSDN.. thanks tom! – Roland Andreas Sep 22 '17 at 06:24
6

Either create a proxy class and include it in your application or add a web reference to ReportingService. The tutorial is available there:

http://technet.microsoft.com/en-us/library/ms155134.aspx

Note that if you are going for proxy class and you are using more than one endpoint (ReportExecution, ReportingService) you should generate proxy classes on different namespaces, otherwise you will get clashes.

Did you do it by web reference? If so, try using WSDL at the command line. Command line syntax:

wsdl /language:CS /n:"Microsoft.SqlServer.ReportingServices2010" http://serverName/reportserver/ReportService2010.asmx?wsdl
P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
kyooryu
  • 1,469
  • 3
  • 23
  • 48
  • I have done this. The proxy class can be generated by adding a reference to a web service in visual studio. That's how I did it and where the `ReportingService2010SoapClient` comes from. – P.Brian.Mackey Sep 23 '13 at 16:44
  • I also tried adding ReportingService2010 to a different class in case there was a namespace conflict. Still no go. – P.Brian.Mackey Sep 23 '13 at 16:48
  • Did you do it by web reference? If so, try using WSDL - I cannot really help you with adding references in VS, because I am experienced only with using proxy classes in the area of SSRS endpoints. – kyooryu Sep 23 '13 at 16:51
  • Using the command line to generate the proxy class worked! Geez, wish I knew what the heck was up with the web service option failing to generate the proxy?!! – P.Brian.Mackey Sep 23 '13 at 16:58
1

Do not add a Webreference

Follow the following steps and it would work just fine.

1) Make sure you have .netframework >= 4.6.1

2) Run command prompt as administrator

3) cd C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools

4) Generate class: wsdl /proxyusername:Username /proxypassword:Password -out:Reportingservice2010.cs http://Servername/Reportserver/ReportService2010.asmx?wsdl

Additional) Run wsdl /? for help Files will output in: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools

5) Add the .cs file to your project

Bernard Walters
  • 391
  • 1
  • 4
  • 16
  • This should be a comment, not an answer. If it is a duplicate question, [vote to close](http://stackoverflow.com/help/privileges/close-questions) as such and/or leave a comment once you [earn](http://meta.stackoverflow.com/q/146472/169503) enough [reputation](http://stackoverflow.com/help/whats-reputation). If it is not an exact duplicate, tailor the answer to fit this particular question. – Xavi López Nov 24 '16 at 13:17
  • @XaviLópez I will close it and leave the fix here – Bernard Walters Nov 24 '16 at 13:21
0

Change this;

private readonly ReportingService2010 _rs = new ReportingService2010()

to

private readonly ReportingService2010SoapClient _rs = new ReportingService2010SoapClient()

You are attempting to create an instance to a class that does not exists and adding the reference creates a corresponding *Client class for you to instantiate.

ChrisBint
  • 12,773
  • 6
  • 40
  • 62
  • `ReportingService2010Client` also does not exist. The closest thing I have is `ReportingService2010SoapClient`... – P.Brian.Mackey Sep 23 '13 at 16:32
  • Updated the answer accordingly – ChrisBint Sep 23 '13 at 16:33
  • I tried this earlier. The classes do not match. For example, `ListChildren()` accepts two parameters in the NON-soap version. The soap version wants 4 parameters. http://technet.microsoft.com/en-us/library/reportservice2010.reportingservice2010.listchildren.aspx – P.Brian.Mackey Sep 23 '13 at 16:36