How to access SharePoint List with List Web Service

SharePoint List Web service allow developers to access, manipulate List and List items through a service url.

Generally List web service url format is : http://site/_vti_bin/lists.asmx

Now lest start consuming this service and manage SharePoint List.
Open this url:
http://spsite:1985/_vti_bin/lists.asmx
Open Visual Studio 2010.
Right click on project and add service reference.

Then click on Advanced… (Refer below screen shot)




Click on Add web reference…

Enter service url and click
 on arrow ->
Give a name to the web reference name , click on Add Reference.
I gave SPSiteRef

Now write this in a console application:


SPSiteRef.Lists objList = new Lists();
Lists listReference = new Lists();      
listReference.Url = "http://spsite:1985/_vti_bin/lists.asmx";
listReference.Credentials = CredentialCache.DefaultCredentials;
//To Add a List
listReference.AddList("MyListtest", "This is a list created by service", 100);

//To Delete a list

listReference.DeleteList("MyListtest");

Few more Methods are:
UpdateList, UpdateListItems, GetListItems ....

Comments

Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX