当前位置: 首页>>网站问题>>正文


Web服务或客户端对象模型?

webfans 网站问题 , , , , 去评论

问题描述

我正在编写一个Silverlight控件,它将显示SharePoint列表中的数据,以便在SharePoint 2010站点中使用。

我正在考虑使用客户端对象模型或SharePoint Web服务来实现此任务?

在决定何时使用时,是否有任何标准或性能考虑因素?

Update

SPServces的作者在这个主题上有一篇文章。包括以下链接

http://sympmarc.com/2012/04/12/when-to-choose-spservices-vs-the-client-side-object-model-csom/#comment-23489

最佳解决方案

如果可以,您应该使用客户端对象模型(CSOM) – 它不支持许多功能作为Web服务,但在许多方面都是优越的,例如:

  • 数据类型

  • 批量命令(更有效地使用带宽)

  • 加载数据的优化(更有效地使用带宽)

  • 在编程方面更类似于服务器端对象模型(Web服务在大多数情况下只是需要解析的大量未记录的XML)

因此,对于性能,您可能会使用CSOM更好地取得成功

次佳解决方案

根据this link使用客户端对象模型时实际调用Web服务。当然使用Web服务更直接但我并不真正关心使用客户端对象模型的性能损失。使用客户端对象模型可以提高生产力。但如果您更习惯使用Web服务,则可以使用它。

第三种解决方案

客户端对象模型主要用于列表数据,因此API受到某种程度的限制。使用Web服务并不总是意味着解析XML数据,您可以使用将返回JSON输出的REST API(ListData.svc)。一些Web服务允许在SOAP和JSON响应格式之间切换。因此,我的建议是在适当时使用客户端对象模型(列表,安全性),并在其他方案中调用SharePoint Web服务。

第四种方案

我认为使用Client-Object模型是合适的选择,因为它意味着与Silverlight,.NET等工具一起使用。

它还提供更多的好处。

第五种方案

在回答此问题时,还应列出此MSDN文章:Deciding Which SharePoint 2010 API to Use

Server-side Object Model

The server-side object model provides the most extensive set of options for extending the capabilities of SharePoint 2010. It consists of every API that is documented in a class library in the SharePoint 2010 Class Libraries and Web Service References section of the Microsoft SharePoint 2010 Software Development Kit (SDK). Any application that uses these APIs must be physically deployed on the server. See Setting Up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7, and Windows Server 2008 for guidance on and options for setting up a development environment. In terms of security, these APIs usually have a high level of access, but see Sandboxed Solutions for limitations that are related to sandboxed solutions. This set of APIs provides access to the largest number of features and capabilities. In Microsoft SharePoint Foundation 2010, many of the server-side APIs reside in the Microsoft.SharePoint assembly (Microsoft.SharePoint.dll); in Microsoft SharePoint Server 2010, many of these APIs reside in the Microsoft.Office.Server assembly (Microsoft.Office.Server.dll). However, you must look at the documentation for each type and member in each API to determine which assembly to reference.

Client Object Model

The client object model allows you to integrate SharePoint 2010 capabilities into script that executes in the browser, code (no earlier than Microsoft .NET Framework 3.5) that executes in a .NET Framework managed application, or code that executes in a Microsoft Silverlight application. The APIs in the client object model are wrappers around a custom Web service that dispatches the calls to the server-side object model. They generally provide better performance than the SharePoint 2010 Web services because they batch requests and perform all operations asynchronously. They also feature design traits (such as object model hierarchy, object identity, data retrieval semantics, client context, infrastructural client objects, collections, and exception handling) that are familiar to SharePoint 2010 developers, and to Microsoft ASP.NET developers more generally. SharePoint 2010 provides an unmanaged ECMAScript (JavaScript, JScript) object model for script that executes in the browser. The unmanaged client object model is a good option for Web developers who are not familiar with ASP.NET development. The client object model focuses on the most relevant APIs for client-side development, and does not contain all the types and members that are represented in the server-side object model. The client object model is designed for use in remote client-side solutions that run on computers where SharePoint 2010 is not installed. See SharePoint 2010 Client Object Model for more information about the client object model and how to use it. The types and members in these APIs are documented in Client Class Library (for code that executes in a .NET managed application or in a Microsoft Silverlight 2.0 application) and JavaScript Class Library (for code that executes in the browser).

SharePoint 2010 Web Services

The SharePoint 2010 Web services allow you to integrate SharePoint capabilities into code that runs remotely in client-side or server-side applications that run on computers where SharePoint 2010 has not been installed. SharePoint 2010 provides a limited set of REST interfaces for developers who are familiar with that standard. The Web services provide a fuller range of capabilities than the managed client object model, but they do not provide the same performance and design advantages, such as batching and exception handling. When you develop client-side applications, you should use the managed client object model whenever possible. The SharePoint 2010 Web services APIs are documented in SharePoint 2010 Web Services and in SharePoint Foundation REST Interface.

参考资料

本文由朵颐IT整理自网络, 文章地址: https://duoyit.com/article/2076.html,转载请务必附带本地址声明。