65.9K
CodeProject 正在变化。 阅读更多。
Home

如何在 Web 应用程序中使用 SharePoint Web 服务

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.54/5 (5投票s)

2008年8月25日

CPOL
viewsIcon

39642

如何在 Web 应用程序中使用 SharePoint Web 服务

引言

如何在 Web 应用程序中使用 SharePoint Web 服务。这个过程非常简单,只需将 Web 引用添加到 Web 服务并开始使用即可。

1-将 Web 服务引用添加到您的项目

以下是我使用的 SharePoint Web 服务列表

1-DWS-创建删除文件夹

2-Lists-显示文档和文件夹列表

3-Copy-将文档从 SharePoint 上的一个文件夹复制到另一个文件夹

 1-How to create a folder from the web application onto the sharepoint.I have use the SharePoint webservice called DWS
var dwsService = new Dws();

dwsService.Credentials = new NetworkCredential("Tanveer", "Test", "MyDomain");

dwsService.Url = SharePointWebServiceLocation + "dws.asmx";

dwsService.CreateFolder(FolderLocation.Replace(" ", "%20") + "/" + NewFolderName.Replace(" ", "%20"));

 2-How to  Delete Folder?.
var dwsService = new Dws();

dwsService.Credentials = new NetworkCredential("Tanveer", "Test", "MyDomain");

dwsService.Url = SharePointWebServiceLocation + "dws.asmx";

dwsService.DeleteFolder(FolderLocation.Replace(" ", "%20"));

 3-How to delete a document-List webservice is used for this

var listService = new Lists();

listService.Credentials = new NetworkCredential("Tanveer", "Test", "MyDomain");

listService.Url = SharePointWebServiceLocation + "lists.asmx";

string strBatch = "<Method ID='1' Cmd='Delete'>" +

"<Field Name='ID'>1</Field>" +

"<Field Name='FileRef'>" + Filepath + "</Field></Method>";

var xmlDoc = new XmlDocument();

XmlElement elBatch = xmlDoc.CreateElement("Batch");

elBatch.SetAttribute("OnError", "Continue");

elBatch.SetAttribute("PreCalc", "TRUE");

elBatch.SetAttribute("RootFolder", FileParentPath);

elBatch.InnerXml = strBatch;

XmlNode ndReturn = listService.UpdateListItems(NodeName, elBatch);
3: To copy user can use the copy web services 
4: To move a document , make a copy of the document and then use the list 
UpdateListItem method to delete the old document

关注点

C#,SharePoint,Asp.net

© . All rights reserved.