0
votes

I'm trying to access Sharepoint 2010's Lists.asmx web service. I've created new console project in C#, added reference to a web service (http://[SITE]/_Vti_Bin/Lists.asmx) and it found the Lists web service all right. However, when I try to do

ListsService.Lists objLists = new ...

It says that Lists does not exist! In object viewer, I see all sorts of things in the ListsService namespace:

AddAttachmentRequest
AddAttachmentRequestBody
....

but I don't see Lists. However, every example I found online says that after I add a reference, I should have Lists in the namespace...

What am I doing wrong?

EDIT: app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="ListsSoap" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://SITE/_Vti_Bin/Lists.asmx"
            binding="basicHttpBinding" bindingConfiguration="ListsSoap"
            contract="ListsService.ListsSoap" name="ListsSoap" />
    </client>
</system.serviceModel>
</configuration>
2

2 Answers

0
votes
  1. Make sure you are doing ListsService.Lists objLists = new ListsService.Lists() (not "new Lists()")

  2. Make sure that the web service reference is setup correctly in the Settings.settings file and web.config/app.config file. Try removing the web service reference and re-adding it

0
votes

The problem was that I have created "service" reference, not a "web service" reference. You have to click "Advanced" and then "Add Web Service reference" in order to add a web service refernce, otherwise it creates a WCF service reference that works differently.