日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SharePoint的WebService的应用

發布時間:2025/5/22 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SharePoint的WebService的应用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

SharePoint自帶了WebService,通常情況下是跨服務器的訪問,因為同一服務器上不同網站可以簡單的通過提升權限代碼就可以訪問數據。

以跨服務器讀取某個list為例,對項目添加“http://<server-url>/_vti_bin/Lists.asmx”和“http://<server-url>/_vti_bin/SiteData.asmx”的引用。

對兩個引用的命名分別為ListService和SiteDataService

//訪問列表庫,通過CAML查詢返回的是一個XML文件,不需要解析直接給DataSet類型賦值

?public static DataSet GetItems()

??????? {
??????????? ListService.Lists listsWS = new ListService.Lists();
??????????? //listsWS.Credentials = System.Net.CredentialCache.DefaultCredentials; //該句在編譯環境可以代替下一句,但是跨服務器應用肯定要用下一句
??????????? listsWS.Credentials = new NetworkCredential(用戶名, 密碼, 域名);
??????????? XmlDocument doc = new System.Xml.XmlDocument();
??????????? doc.LoadXml("<Document><Query><Where>CAML</Where></Query><ViewFields /><QueryOptions /></Document>");
??????????? XmlNode listQuery = doc.SelectSingleNode("//Query");
??????????? XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
??????????? XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");

??????????? Guid g = GetWebID();
????????? ?
??????????? XmlNode items = listsWS.GetListItems("ListName", string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, g.ToString());

??????????? NameTable nt = new System.Xml.NameTable();
??????????? XmlNamespaceManager nsMgr = new XmlNamespaceManager(nt);
??????????? nsMgr.AddNamespace("w", "http://schemas.microsoft.com/office/word/2003/2/wordml");
??????????? XmlNode y = items.SelectSingleNode("*", nsMgr);
??????????? DataSet ds = new DataSet();
??????????? if (y != null)
??????????? {
??????????????? XmlReader xmlReader = new XmlTextReader(y.InnerXml, XmlNodeType.Element, null);
??????????????? ds.ReadXml(xmlReader);
??????????? }
??????????? return ds;
??????? }

??????? private static Guid GetWebID()
??????? {
??????????? SiteDataService.SiteData siteDataWS = new sinopecSiteData.SiteData();
??????????? siteDataWS.Credentials = new NetworkCredential(用戶名, 密碼, 域名);
??????????? SiteDataService._sWebMetadata webMetaData;
??????????? SiteDataService._sWebWithTime[] arrWebWithTime;
??????????? SiteDataService._sListWithTime[] arrListWithTime;
??????????? SiteDataService._sFPUrl[] arrUrls;
??????????? string roles; string[] roleUsers; string[] roleGroups;?????
??????????? uint i = siteDataWS.GetWeb(out webMetaData, out arrWebWithTime, out arrListWithTime, out arrUrls, out roles, out roleUsers, out roleGroups);
??????????? Guid g = new Guid(webMetaData.WebID);
??????????? return g;

??????? }

?以上代碼要特別注意兩點:

1。身份驗證。對web引用可以直接在webconfig里面直接修改地址,相應的修改代碼中的驗證登錄信息就可以,建議都弄到配置文件里,方便統一維護。

2。解析XML。

?

以下是引用的service對應的映射列表

WSS Web ServicesWeb Reference
Administration Servicehttp://<server-url:port-number>/_vti_adm/admin.asmx
Alerts Servicehttp://<server-url>/_vti_bin/alerts.asmx
Document Workspace Servicehttp://<server-url>/_vti_bin/dws.asmx
Forms Servicehttp://<server-url>/_vti_bin/forms.asmx
Imaging Servicehttp://<server-url>/_vti_bin/imaging.asmx
List Data Retrieval Servicehttp://<server-url>/_vti_bin/dspsts.asmx
Lists Servicehttp://<server-url>/_vti_bin/lists.asmx
Meetings Servicehttp://<server-url>/_vti_bin/meetings.asmx
Permissions Servicehttp://<server-url>/_vti_bin/permissions.asmx
Site Data Servicehttp://<server-url>/_vti_bin/sitedata.asmx
Site Servicehttp://<server-url>/_vti_bin/sites.asmx
Users and Groups Servicehttp://<server-url>/_vti_bin/usergroup.asmx
Versions Servicehttp://<server-url>/_vti_bin/versions.asmx
Views Servicehttp://<server-url>/_vti_bin/views.asmx
Web Part Pages Servicehttp://<server-url>/_vti_bin/webpartpages.asmx
Webs Servicehttp://<server-url>/_vti_bin/webs.asmx

?

?

轉載于:https://www.cnblogs.com/Hary/archive/2009/02/04/1383933.html

總結

以上是生活随笔為你收集整理的SharePoint的WebService的应用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。