Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>Use SharePoint web services instead of the object model</h3> <p>If you need to work with a remote sharepoint server, you can use the web services instead of the object model. </p> <p>Assuming you have added a reference to the lists webservice (/_vti_bin/lists.asmx), and called it "Lists", you can get a list of visible lists like this:</p> <pre><code>Lists.Lists proxy = new Lists.Lists(); // Use logged on users credentials to authenticate with SharePoint proxy.Credentials = CredentialCache.DefaultNetworkCredentials; XmlNode listCollection = proxy.GetListCollection(); foreach (XmlNode node in listCollection.ChildNodes) { bool hidden = bool.Parse(node.Attributes["Hidden"].Value); if (!hidden) { Console.WriteLine(node.Attributes["Title"].Value); } } </code></pre> <p>You can find more details on the lists web service here: <a href="http://msdn.microsoft.com/en-us/library/lists.lists_methods.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/lists.lists_methods.aspx</a></p> <p>Most of the things you can do with object model code can also be achieved using web services.</p> <h3>Adding a reference to the web service</h3> <p>To add a web reference in VS2010:</p> <ol> <li><p>Right click on the project node in Solution Explorer, and select <strong>Add Service Reference</strong></p></li> <li><p>In the <em>Add Service Reference</em> dialog, click on <strong>Advanced...</strong></p></li> <li><p>In the <em>Service Reference Settings</em> dialog, click on <strong>Add Web Reference...</strong></p></li> <li><p>In the <em>Add Web Reference</em> dialog:</p> <p>a. For <em>Url</em>, enter the site collection url followed by <strong>_vti_bin/lists.asmx</strong>. For example: <a href="http://sharepoint/sites/mySiteCollection/_vti_bin/lists.asmx">http://sharepoint/sites/mySiteCollection/_vti_bin/lists.asmx</a></p> <p>b. For <em>Web reference name</em>, enter <strong>Lists</strong></p> <p>c. Click <strong>Add Reference</strong></p></li> </ol> <p>The reference will now be added to the project, and you can use the code above to access it. </p> <p>To get lists from sub-site, change the services URL property to point to the web service for that sub-site by adding <strong>_vti_bin/lists.asmx</strong> to the sub-site's url as above.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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