WebService读取 SharePoint列表
来源:互联网 发布:局域网网络监视软件 编辑:程序博客网 时间:2024/05/22 02:39
提示虚拟一个管理员。
SPSecurity.RunWithElevatedPrivileges(delegate() //虚拟管理员,否则其他用户访问没有权限
1、 新建一个WebService的项目,选择Asp.net Web服务应用程序,然后输入项目名称
2、 添加引用
添加Microsoft.SharePoint.dll文件的引用,因为我们需要使用SharePoint的对象模型来读取列表信息,Dll文件的位置是C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll
3、 添加函数
函数前面写上[WebMethod]标记,然后定义我们自己需要的方法,方法的参数和返回值,在方法里面,写我们的调用,我的代码就是个简单的例子,返回的也都是String类型,如果操作失败,则返回为空。
GetListItem(string WebUrl,string ListName,int ID)//获取列表项,传参分别为网站地址、列表名、ID
public string GetWebID(string WebUrl)//获取网站的WebID属性
[WebMethod]public string GetWebID(string WebUrl){try{
SPSecurity.RunWithElevatedPrivileges(delegate() //虚拟管理员,否则其他用户访问没有权限 {SPSite site = new SPSite(WebUrl);SPWeb web = site.OpenWeb();return web.ID.ToString();}catch (Exception ex){return "";}}
}[WebMethod]public string GetListItem(string WebUrl, string ListName, int ID){try{
SPSecurity.RunWithElevatedPrivileges(delegate() //虚拟管理员,否则其他用户访问没有权限 {SPSite site = new SPSite(WebUrl);SPWeb web = site.OpenWeb();SPListItem item = web.Lists[ListName].Items[ID];String rt = "标题:" + item["Title"].ToString() + "内容:" + item["内容"].ToString();return rt;}catch (Exception ex){return "";}}
}
发布到IIS以后,打开我们的WebService,可以看到我们的自定义的两个方法,都在WebService中了。4、 发布WebService后测试
5、 使用两个函数
我们可以分别测试下我们的两个函数,点击我们的函数,可以进入下面的界面,输入我们的参数,调用即可。
6、 调用结果
如果,可以看出我们调用的结果,下面第一张图是GetListItem(string WebUrl,string ListName,int ID)函数的,第二张图是GetWebID(string WebUrl)的结果。
纯手写:群 212099235
- WebService读取 SharePoint列表
- SharePoint 列表项通过自定义WebService读取
- sharepoint 2013 如何创建一个webservice获取sharepoint列表数据
- 通过WEB SERVICE读取SHAREPOINT列表数据
- 使用对象模型读取SharePoint列表
- sharepoint利用webservice对列表进行增,删,改
- SharePoint WebService
- 读取InfoPath中的附件并附加至SharePoint列表
- SharePoint WebPart 简单的读取列表内容的web部件
- 使用客户端对象模型读取SharePoint列表数据
- sharepoint webservice getListFieldInternalName
- webservice for sharepoint 2010
- java调用sharepoint webservice
- SharePoint 读取Oracle webservice “已超过传入消息(65536)的最大消息大小配额。”
- sharepoint 2010\2013 从列表中读取列值放在集合中
- sharepoint 2003 补丁列表
- sharepoint列表关联
- sharepoint 代码创建列表
- Java 多线程优先级
- android获取地理位置信息
- Red5 高性能启动问题
- AAuto - 快速搜索文件
- MySQL 存储过程 创建 查看 调用 删除
- WebService读取 SharePoint列表
- UVa 10132 - File Fragmentation
- CSDN的第一篇文章!
- iOS开发24:使用SQLite3存储和读取数据
- 从如何解决问题到如何学习算法
- 开篇---起点---记录点滴
- 程序人生--2000年(1)
- Source code for nltk.tokenize.texttiling
- PHP常用算法