Limitations of SharePoint Web Services

Preface

SharePoint is a very vast topic to discuss. There are many documents, articles, discussion forums and FAQs available on the internet discussing various aspects of SharePoint. Still, getting consolidated information on some topics seems to be very difficult. The topic discussed here is one among them.

Scope

This article is an attempt to list down the limitations (in functionalities) of SharePoint Web Services compared toSharePoint Object Model.

This article is based on the below listed SharePoint versions:

  • Windows SharePoint Services 3.0 (WSS 3.0)
  • SharePoint Portal Server 2003 (SPS 2003)
  • Microsoft Office SharePoint Server 2007 (MOSS 2007)

This document does not discuss the usage of SharePoint Object Model or SharePoint Web Services, but focuses mainly on the limitation of SharePoint Web Services. This article does not discuss the details of SharePoint RPC or FrontPage Extension RPC.

Pre-Requisites

This article expects that you are familiar with:

  • The concepts and usage of Web Services in general and related terms like WSDL, SOAP, XML, WebMethod, etc.
  • Basic .NET concepts of Assembly, Namespace, Class, etc.
  • The samples in the document are in C#, so familiarity with the same will also help to understand the discussed topic better.

Contents

  1. A Brief Introduction
  2. Performance Overhead of SP Web Service
  3. Limitation in Retrieving WebApps, SiteCollections
  4. Finding SharePoint Version
  5. Issues with Downloading Data
  6. Limitation in Retrieving Item Level Permissions

A Brief Introduction

What is SharePoint Object Model?

SharePoint Object Model is a .NET-based application programming interface (API) to SharePoint components which can be used to interact with a SharePoint Server. It can be used to communicate with all SharePoint components like Web Applications, Site Collections, Sites, Permissions, Roles, Users, Change Logs, etc.

Applications written using SharePoint Object Model require to be run on the SharePoint Server itself. It is not possible to use it to work remotely with a SharePoint Server. The Object Model is provided purely for server side programming. It can be used to extend the functionalities of the SharePoint server. Some examples are:

  • To create some server side tools that lists the Web Applications, Site Collections or all Sites in a SharePointFarm
  • Writing custom web services, etc.

In a SharePoint farm which has more than one server, the application should be run on any of the Web Front End servers, which has the required SharePoint Assemblies (e.g. Microsoft.SharePoint.dll).

What is SharePoint Web Services?

SharePoint provides a set of Web Services that you can use to work remotely with a deployment of SharePoint. It provides methods for Administration, Alerts, Authentication, Copy, Document Work Space, Meetings, etc.

You can also run Web Service client applications on the server, but it will not provide any benefit in terms of performance or functionalities. Other methods or protocols which can be used for remote communication withSharePoint are SharePoint RPC (Remote Procedure Call) and FrontPage Extensions RPC.

In SharePoint 2010, Microsoft introduced a new object model known as Client Object Model, which can also be used to work remotely with SharePoint. Using Client Object Model, you can avoid directly interacting with Web Services.

Please refer to the official documentation on SharePoint Web Services to get the comprehensive list of features offered.

Performance Overhead of SP Web Service

Web Service in general is slow when compared to other binary communication mechanisms like .NET Remoting. Similarly, SharePoint Web Service is also slower if compared with Object Model.

What are the reasons for the slowness?

  1. Web Services use XML based SOAP (Simple Object Access Protocol) messages as the communication protocol. So every request has a marshalling un-marshalling overhead.
  2. Every request has to be authenticated using user name and password. It does not support the concept of authenticated session, which can be re-used with a session key. (An exception is ExcelService Web Service in MOSS 2007. It supports sessions when opening an Excel Workbook using OpenWorkBook() method.)

Limitation in Retrieving WebApps, SiteCollections

SharePoint Web Service can retrieve the list of Sites (sub sites), Lists and items from a Site collection.

The Webs Web Service can be used to retrieve the Sites and Sub Sites. The access URL of the Web Service ishttp://<site>/_vti_bin/webs.asmx. It provides the below listed methods to retrieve the Sites and Sub sites.

  • GetWebCollection: Returns the titles and URLs of all sites directly beneath the current site.
  • GetAllSubWebCollection: Returns the titles and URLs of all sites within the current site collection

If you want the list of all Site collections or WebApps, there is no way at all using any of the SharePoint Web Services.

Using SharePoint Web Service, it is not possible:

  • To retrieve the list of Site Collections from a SharePoint Farm
  • To retrieve the list of Web Applications
  • To find which is the MySite Host(s)
  • To find MySite URLs of all the users

Finding SharePoint Version

SharePoint Web Services do not provide any direct method to retrieve the version of the SharePoint server. You will have to use the FrontPage extensions RPC to retrieve the server version.

The details of the RPC method can be referred at http://msdn.microsoft.com/en-us/library/ms460198.aspx.

An example usage is:

HttpWebRequest webReq = HttpWebRequest.Create

	("http:/<site>/_vti_bin/shtml.dll/_vti_rpc") as HttpWebRequest;

webReq.Method = WebRequestMethods.Http.Post;

webReq.Credentials = new NetWorkCredential(user, passwd, domain);



StreamWriter strWriter = new StreamWriter(webReq.GetRequestStream());

strWriter.Write 

	("method=server version:server_extension_version&service_name=site_url=/");



HttpWebResponse WebResponse = webRequest.GetResponse() as HttpWebResponse;

String response = new StreamReader(WebResponse.GetResponseStream()).ReadToEnd();

The string response has to be parsed to retrieve the full version information

Issues with Downloading Files

SharePoint allows its users to upload file(s) into the Server (with or without version control). Users can download the uploaded files programmatically or using a Web browser. SharePoint Web Service provides a Copy Service for the purpose of copying data from the server. The Copy Web Service can be accessed by the URL: http://<servername>/_vti_bin/copy.asmx.

The GetItem() method of the Copy service can be used to retrieve a file content from the Server. The syntax ofGetItem() method is:

[SoapDocumentMethodAttribute(http://schemas.microsoft.com/sharepoint/soap/GetItem, 

RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", 

ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", 

Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 

public uint GetItem (

   string Url,

   out FieldInformation[] Fields,

   out byte[] Stream

)

The file data is retrieved in the output parameter Stream. MSDN documentation says “Stream: An array of Bytes, passed as an out parameter that is a base-64 representation of the retrieved document's binary data.”

The overheads here are:

  • Marshalling/un-marshalling overhead: The SharePoint Server encodes the binary file data (e.g. Word, Excel file) into text (using Base64 encoding) in order to send it over Web Service. The client application should decode it back to the original encoding for viewing the file. This can affect performance.
  • Memory overhead: The GetItem() method uses a single buffer to retrieve the whole file content. InSharePoint, the maximum allowed size of a single file for upload is 50 MB by default. But this can be configured and the theoretical limit of file size in SharePoint is 2 GB. So having a single buffer to download a file is not practical due to obvious reasons.

The application programmer should use some alternate stream based mechanisms to download files from theSharePoint instead of using the web service (Copy Service). Here is an example of downloading file using .NETWebClient class.

string url = "http://<Site>/Documents/TestDoc.pdf";

string localfileName = @"c:\downloaded files\TestDoc.pdf";

// Create a new WebClient instance.

WebClient myWC = new WebClient();

// Set the credentials

myWC.Credentials = new NetworkCredential(username, password, domain);

// Download the file and save it into the local path.

myWC.DownloadFile(url, localfileName); 

Limitation in Retrieving Item Level Permissions

In SharePoint, permissions of the parent site are inherited to the List and to items by default. It is also possible to break this inheritance chain of permissions in order to enable unique permissions. Unique permissions can be enabled atSite or List or event at Item level.

There is a Permissions Web Service (http://<Site>/_vti_bin/Permissions.asmx) that is provided for working with permissions. It provides methods for working with the permissions for a site or list only. It is very much surprising that it does not support managing permissions at item level with Web Services.

Let's look at the GetPermissionCollection() method. The syntax is:

[SoapDocumentMethodAttribute

("http://schemas.microsoft.com/sharepoint/soap/directory/GetPermissionCollection", 

RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", 

ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", 

Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 

public XmlNode GetPermissionCollection (

    string objectName,

    string objectType

)

The MSDN says that the parameter objectType should be either List or Web. Other methods in this web service are AddPermissionAddPermissionCollectionRemovePermissionRemovePermissionCollectionand UpdatePermission. The support matrix of object type for all the methods in this web service is given below:

Method Name Supported Object Types
AddPermission List, Web
AddPermissionCollection List, Web
GetPermissionCollection List, Web
RemovePermission List
RemovePermissionCollection List
UpdatePermission List, Web

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

 

http://www.codeproject.com/Articles/63861/Limitations-of-SharePoint-Web-Services

你可能感兴趣的:(web services)