Introduction
Microsoft Office 2003 is very tightly integrated with SharePoint by utilizing its web services. Windows SharePoint Services comes with sixteen different web services. SharePoint Portal Server 2003 supports an additional five web services. The web services provided by SharePoint do provide a vast array of features. But not all SharePoint features are accessible through them. If required you can build your own web service on top of SharePoint leveraging the managed SharePoint server API itself. The web service interfaces make it very easy to integrate SharePoint capabilities right into your application.
This article is not a detailed documentation of every web method and web service provided by SharePoint. It is rather an introduction to its capabilities and how to use them. You can download the Windows SharePoint Services SKD or the SharePoint Portal Server SKD for a complete reference of all web services and also of the server API itself. Please refer to this article for a guide how to install and administrate SharePoint or this article for a guide how to use and customize SharePoint portals.
How to add a Windows SharePoint web service reference
You can add a web reference to each SharePoint web service through your Visual Studio .NET IDE. In your Solution Explorer right click on your project and select "Add Web Reference" from your popup menu. The table below shows the URLs to use for each web service provided by WSS. Enter the URL to the web service and click the Go button. This will show you in the dialog box a summary of all available web methods. Next enter the name of the web reference and then click Add Reference.
WSS Web Services
Web Reference
Administration Service
http:///_vti_adm/admin.asmx
Alerts Service
http:///_vti_bin/alerts.asmx>
Document Workspace Service
http:///_vti_bin/dws.asmx>
Forms Service
http:///_vti_bin/forms.asmx>
Imaging Service
http:///_vti_bin/imaging.asmx>
List Data Retrieval Service
http:// /_vti_bin/dspsts.asmx>
Lists Service
http:///_ vti_bin/lists.asmx>
Meetings Service
http:/// _vti_bin/meetings.asmx>
Permissions Service
http:// /_vti_bin/permissions.asmx>
Site Data Service
http:///_vti_bin/sitedata.asmx>
Site Service
http:///_vti_bin/sites.asmx>
Users and Groups Service
http:///_vti_bin/usergroup.asmx>
Versions Service
http:///_vti_bin/versions.asmx>
Views Service
http:///_vti_bin/views.asmx>
Web Part Pages Service
http:// /_vti_bin/webpartpages.asmx>
Webs Service
http:///_vti_bin/webs.asmx>
Setting the web service user credentials
The SharePoint web services only accept calls from existing SharePoint users and do also enforce access security. Import the System.Net namespace into your project and then use the NetworkCredential class to set the user credential to use for the web service call. Here is a code snippet:
public static XmlNode VersionsGetVersions(string SharePointHost, string UserName, string Password, string Domain, string FileName)
{
// proxy object to call the Versions web service
Versions.Versions VersionsService = new Versions.Versions();
// the user credentials to use
VersionsService.Credentials = new NetworkCredential(UserName, Password, Domain);
VersionsService.Url = SharePointHost + "_vti_bin/Versions.asmx";
// gets the file versions
XmlNode Result = VersionsService.GetVersions(FileName);
// dispose the web service object
VersionsService.Dispose();
return Result;
}
For example, first you create an instance of the Versions web service. Then you assign a new instance of the NetworkCredential class to the Credentials property on the created web service object. We pass along the user name, password and the user's domain name to the NetworkCredential object. Next you set the web service URL, which might very well be different from the one used when you created the web reference. Finally you invoke the desired web method, in the code snippet above the GetVersions() web method. The web method takes a file name and returns a XML document with all available versions of this file (Document libraries can have versioning enabled and then keep a history for each version). At the end you call Dispose() on the web service object to free up any underlying unmanaged resources.
If the user does not exist in SharePoint or does not have the permission to perform the operation then a WebException is thrown by SharePoint. The returned HTTP status is 401, which means unauthorized request. There are some inconsistencies across all web services. For example some web methods take a XML string as input while others take an XmlNode as input. Most web methods return the result as XmlNode while others return a XML string and while others again return complex data structures. But after you get used to these inconsistencies it is very easy to use these web services and integrate SharePoint capabilities right into your application.
A summary of the "Windows SharePoint Services" web services
The following table provides an overview what capabilities are exposed through the "Windows SharePoint Services" web services. Each web service is targeted towards a specific area although there is some overlap. You for example can use the Lists web service and the Site Data web service to work with SharePoint lists, or you can use the Site Data web service and the Webs web service to work with sites meta-data and sub-sites. Please refer to the attached "SharePoint web service browser" sample application which provides a windows form interface to browse all web services and all its web methods. It enables you to play with each web method or web service and better understand its usage. It also displays to each web service and web method the detailed SDK help page.
| WSS Web Services | Description |
| Administration Service | This web service provides administrative capabilities like creating a new top-level site, deleting a top-level site and getting the list of available languages. |
| Alerts Service | Provides access to the list of active alerts and allows to delete active alerts. |
| Document Workspace Service | This web service is used to manage Document Workspace sites. It allows to create new document workspaces, delete document workspaces, create new sub-folders, delete sub-folders, etc. |
| Forms Service | Each list has forms associated which are used to display list items, create new list items and update or delete existing list items. This web service allows to get the collection of forms associated with a list and then get detailed information about each form. |
| Imaging Service | SharePoint has picture libraries which users can use to manage pictures. This web service allows to upload pictures, download pictures, create new folders, delete folders and pictures, etc. |
| List Data Retrieval Service | Allows to run XPath like queries against a list. |
| Lists Service | This web service is used to work with lists and list data. You can obtain the collection of lists, add new lists, remove lists, add new list attachments, remove attachments, etc. |
| Meetings Service | This web service is used to work with Meeting Workspaces. You can create a new Meeting workspace, remove an existing Meeting workspace, add new meetings, add new meetings using ICal files, etc. |
| Permissions Service | Sites and lists have permissions assigned to them. This web service is used to obtain the permissions assigned to a list or site, add new permissions and update or removing existing permissions. |
| Site Data Service | The Site Data web service can be used to return meta-data about a site or list, get the collection of lists, get the attachments for a list item, get the collection of items in a list, etc. |
| Site Service | This web service can be used to return the list of site templates. When you create a new site using the Administration web service you need to specify the site template name to use which you can obtain through this web service. |
| Users and Groups Service | This web service is used to work with users, site-groups and cross-site groups. You can add, update or remove users, site-groups and cross-site groups. You can also add users or cross-site-groups to a site-group. |
| Versions Service | Document Libraries and Picture Libraries can have versioning enabled, which stores a copy of every single file version. This web service can be used to get the list of available versions, delete versions and also restore a file version. |
| Views Service | Lists have views associated which define what fields are shown, what filtering and sorting is applied, what grouping is applied, etc. This web service is used to work with list views. You can get the collection of views, add new views, remove views, update the Html code used to display a view, etc. |
| Web Part Pages Service | Web Parts are objects which you can place on web part pages. This web service is used to work with web parts and web part pages. You can get the list of web parts on a page, you can add or remove web parts, etc. |
| Webs Service | This web service is used to work with sites and sub-sites. You can get the list of list-templates, get meta-data about a sub-site, get the list of sub-sites, etc. |
sara rathPosted Jan 6, 2010, 12:36 AM
thanks klaus for these valuable information, reders may try this, ADD|Update|Delete Item SharePoint Web Services
MarioPosted Oct 6, 2009, 6:01 AM
Thanks Klaus, very good article.
Mahesh ChandeditedPosted Jul 17, 2006, 1:45 PMEdited Jan 3, 2007, 4:53 PM
Very good introducto Subject : Informative Posted By : mahesh Posted Date : 7/17/2006 1:45:12 PM Very good introductory article. ry article. Editor’s Desk <!--End-Editorial--><!-- Start Mike's Corner --> 's Corner <!-- End Mike's Corner --><!--Begin-Sponsers--> Sponsors ReSharper Dundas Software .net Commerce ceTe Software RedGate Software <!-- View all sponsors --> <!--End-Sponsers--><!--Begin-Top Articles--> Top Articles <!--End-Top Articles--><!--Begin-Hot Consultants--> Hot Jobs <!--End-Featured Jobs--> <!--End-Hot Consultants--><!--Begin-Hot Consultants--> Hot Consultants <!--End-Featured Jobs--> <!--End-Hot Consultants--><!--Begin-Top Authors--> Top Authors <!--End-Top Authors--><!--Begin-Featured Reviews--> Featured Review <!-- End Featured Review --><!--Begin-Recent Reviews--> Featured Products <!--End-Featured Consultants--><!--Begin-New Member--><!-- New Members --><!--End-New Member-->