Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>Visual Studio 2005</h2> <ol> <li>Create a new console application project in Visual Studio</li> <li>Add a "Web Reference" to the Lists.asmx web service. <ul> <li>Your URL will probably look like: <code>http://servername/sites/SiteCollection/SubSite/_vti_bin/Lists.asmx</code></li> <li>I named my web reference: <code>ListsWebService</code></li> </ul></li> <li>Write the code in program.cs (I have an Issues list here)</li> </ol> <p>Here is the code.</p> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.Xml; namespace WebServicesConsoleApp { class Program { static void Main(string[] args) { try { ListsWebService.Lists listsWebSvc = new WebServicesConsoleApp.ListsWebService.Lists(); listsWebSvc.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; listsWebSvc.Url = "http://servername/sites/SiteCollection/SubSite/_vti_bin/Lists.asmx"; XmlNode node = listsWebSvc.GetList("Issues"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } } </code></pre> <hr> <h2>Visual Studio 2008</h2> <ol> <li>Create a new console application project in Visual Studio</li> <li>Right click on References and Add Service Reference</li> <li>Put in the URL to the Lists.asmx service on your server <ul> <li>Ex: <code>http://servername/sites/SiteCollection/SubSite/_vti_bin/Lists.asmx</code></li> </ul></li> <li>Click Go</li> <li>Click OK</li> <li>Make the following code changes:</li> </ol> <p>Change your app.config file from:</p> <pre><code>&lt;security mode="None"&gt; &lt;transport clientCredentialType="None" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt; &lt;/security&gt; </code></pre> <p>To:</p> <pre><code>&lt;security mode="TransportCredentialOnly"&gt; &lt;transport clientCredentialType="Ntlm"/&gt; &lt;/security&gt; </code></pre> <p>Change your program.cs file and add the following code to your Main function:</p> <pre><code>ListsSoapClient client = new ListsSoapClient(); client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; XmlElement listCollection = client.GetListCollection(); </code></pre> <p>Add the using statements:</p> <pre><code>using [your app name].ServiceReference1; using System.Xml; </code></pre> <p>Reference: <a href="http://sharepointmagazine.net/technical/development/writing-caml-queries-for-retrieving-list-items-from-a-sharepoint-list" rel="noreferrer">http://sharepointmagazine.net/technical/development/writing-caml-queries-for-retrieving-list-items-from-a-sharepoint-list</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload