Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

SharePoint Web Service Reference

$
0
0

Hi folks,

I have added a service reference to the SharePoint Lists web service to my 2012 project and have written the following code to retrieve items from the 'Tasks' list.

           try
            {
                const string listName = "Tasks";

                var client = new ListsSoapClient("ListsSoap");
                var query = new XElement("Query", "");
                var viewFields = new XElement("ViewFields", "");
                var queryOptions = new XElement("QueryOptions", "");

                var result = client.GetListItems(listName, null, query, viewFields, null, queryOptions, null);

                Console.WriteLine(result);

            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }

Unfortunately when constructing the ListsSoapClient an exception is throw and the following message displayed:

Could not find endpoint element with name 'ListsSoap' and contract 'ListsWS.ListsSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

My app.config file was generated when the service reference was added:

<?xml version="1.0" encoding="utf-8" ?><configuration><system.serviceModel><bindings><basicHttpBinding><binding name="ListsSoap" /></basicHttpBinding></bindings><client><endpoint address="http://domain/sites/930/_vti_bin/Lists.asmx"
                binding="basicHttpBinding" bindingConfiguration="ListsSoap"
                contract="ListsWS.ListsSoap" name="ListsSoap" /></client></system.serviceModel></configuration>

I can see a basicHttpBinding with the name 'ListsSoap', so why the exception?

Help is very much appreciated. Thanks in advance.



Viewing all articles
Browse latest Browse all 21115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>