SharePoint 2013 App Development读书笔记5
来源:互联网 发布:怎么加油最省钱 知乎 编辑:程序博客网 时间:2024/04/28 03:33
使用客户端对象模型(Client-Side Object Model,即CSOM)和REST API来开发app,针对不同的host环境,有不同的限制,可以参考下图:
这张图告诉我们,如果开发SharePoint-hosted的app,只能使用javascript调用CSOM或者REST API,
如果开发Provider或者auto-hosted的app,可以使用C#来调用CSOM或者REST(当然这些C#代码是运行在remote web中的),也可以使用js来调用REST,但是不能使用JS调用CSOM。
使用客户端对象模型访问SharePoint
这张架构图的左边部分是使用客户端对象模型访问SharePoint的App,右边是SharePoint服务端,可以看到,在客户端有两种方式,一种是供JS调用的CSOM,一种是托管的C#代码调用的CSOM,它们通过web service向SharePoint发送请求(XML格式),接收SharePoint发回的JSON。在服务端处理请求的是Client.svc,它针对客户端的请求,调用服务端代码,返回结果。
使用REST API访问SharePoint
SharePoint 2010的时候,可以通过listdata.svc来访问SharePoint,在SharePoint 2013中,listdata.svc仍旧可以使用,但是推荐使用client.svc。我们可以通过_api来访问client.svc,例如:http://localhost/_api/site将返回站点集的属性(注意如果使用IE浏览器的时候,需要关闭feed view):
<?xml version="1.0" encoding="utf-8" ?> <entry xml:base="http://sp2013test/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"> <id>http://sp2013test/_api/site</id> <category term="SP.Site" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> <link rel="edit" href="site" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/EventReceivers" type="application/atom+xml;type=feed" title="EventReceivers" href="site/EventReceivers" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Features" type="application/atom+xml;type=feed" title="Features" href="site/Features" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Owner" type="application/atom+xml;type=entry" title="Owner" href="site/Owner" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RecycleBin" type="application/atom+xml;type=feed" title="RecycleBin" href="site/RecycleBin" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RootWeb" type="application/atom+xml;type=entry" title="RootWeb" href="site/RootWeb" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/UserCustomActions" type="application/atom+xml;type=feed" title="UserCustomActions" href="site/UserCustomActions" /> <title /> <updated>2014-04-09T01:19:48Z</updated> <author> <name /> </author> <content type="application/xml"> <m:properties> <d:AllowDesigner m:type="Edm.Boolean">true</d:AllowDesigner> <d:AllowMasterPageEditing m:type="Edm.Boolean">false</d:AllowMasterPageEditing> <d:AllowRevertFromTemplate m:type="Edm.Boolean">false</d:AllowRevertFromTemplate> <d:AllowSelfServiceUpgrade m:type="Edm.Boolean">true</d:AllowSelfServiceUpgrade> <d:AllowSelfServiceUpgradeEvaluation m:type="Edm.Boolean">true</d:AllowSelfServiceUpgradeEvaluation> <d:CompatibilityLevel m:type="Edm.Int32">15</d:CompatibilityLevel> <d:Id m:type="Edm.Guid">8e5e5d0c-f242-49e8-bf17-055ec80cf3d0</d:Id> <d:LockIssue m:null="true" /> <d:MaxItemsPerThrottledOperation m:type="Edm.Int32">5000</d:MaxItemsPerThrottledOperation> <d:PrimaryUri>http://sp2013test/</d:PrimaryUri> <d:ReadOnly m:type="Edm.Boolean">false</d:ReadOnly> <d:ServerRelativeUrl>/</d:ServerRelativeUrl> <d:ShareByLinkEnabled m:type="Edm.Boolean">false</d:ShareByLinkEnabled> <d:ShowUrlStructure m:type="Edm.Boolean">false</d:ShowUrlStructure> <d:UIVersionConfigurationEnabled m:type="Edm.Boolean">false</d:UIVersionConfigurationEnabled> <d:UpgradeReminderDate m:type="Edm.DateTime">1899-12-30T00:00:00</d:UpgradeReminderDate> <d:Upgrading m:type="Edm.Boolean">false</d:Upgrading> <d:Url>http://sp2013test</d:Url> </m:properties> </content> </entry>
一些常用的URI:
命名空间:
常用的对象及属性:
使用$select和$order来选择特定的对象和排序
使用$filter来过滤:
使用$top和$skip实现分页获取数据:
代码示例参见:git@code.csdn.net:shrenk/sharepoint-applab.git
- SharePoint 2013 App Development读书笔记5
- SharePoint 2013 App Development读书笔记1
- SharePoint 2013 App Development读书笔记2
- SharePoint 2013 App Development读书笔记3
- SharePoint 2013 App Development读书笔记4
- SharePoint 2013 App Development读书笔记6
- SharePoint 2013 App Development读书笔记7
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第2章节--SharePoint 2013 App 模型概览 SharePoint 2013 App 模型
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第2章节--SharePoint 2013 App 模型概览
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第2章节--SharePoint 2013 App 模型概览 移到云端
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第2章节--SharePoint 2013 App 模型概览 总结
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第2章节--SharePoint 2013 App 模型概览 理解三个SharePoint 部署模型 Apps
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第7章节--打包并部署SP2013 Apps 剖析App
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第7章节--打包并部署SP2013 Apps 部署一个App
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第15章节--开发SP2013工作流应用程序 SP App中的工作流
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第5章节--Windows Azure概览 SharePoint和Windows Azure
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 目录
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第12章节--SP 2013中远程Event Receivers 远程Event Receivers App级别生命周期
- abator教程
- 程序员大雨天不迟到的八大绝招
- 微信公众平台开发(七) 聊天机器人功能开发
- JAVA serializable理解方式记录中!!!
- QAction系列详解
- SharePoint 2013 App Development读书笔记5
- 如何以Java实现网页截图技术
- SQL Server创建索引
- 恢复手机删除的照片怎么做到
- android告别篇-对于源码我的一些看法
- 《python自然语言处理》笔记---chap3加工原料文本
- IE浏览器JSON不兼容问题及浏览器版本问题解决
- Spring Security 3.x 完整入门教程
- Nginx常用的 URL 重写方法