SharePoint發行版本有SharePoint2003、SharePoint2007、Sharepoint 2010、SharePoint2013和SharePoint2016。SharePoint提供了功能強大的團隊協作環境,使得組織能夠在整個組織內部實現整合、組織、查找和提供 SharePoint站點。 在SharePoint的使用中,經常需要進行系統集成這樣的操作,我們作為SharePoint開發,就需要給其他系統提供接口,而SharePoint提供的WebService就很好的提供了這樣的功能,我們簡單了解下,通過SharePoint提供WebService對列表進行操作 步驟: 1、 首先,新建一個控制臺程序,添加WebService的引用 地址http:// 2、引用 - 右鍵 - 添加服務引用(如圖1)– 高級 – 添加Web引用 – URL處填寫WebService地址(如圖2) (圖1) (圖2) 3、 獲取List信息 try { WebServices1.Lists listService = new GetListTest.WebServices1.Lists(); listService.Credentials = System.Net.CredentialCache.DefaultCredentials; XmlNode ndLists = listService.GetList("Test");//參數列表名,String類型 Console.Write(ndLists.OuterXml); } catch (Exception ex) { Console.Write(ex.Message); } 4、 獲取List信息結果 5、 獲取ListItem信息 //獲取ListItem信息 WebServices1.Lists listService = new GetListTest.WebServices1.Lists(); listService.Credentials = System.Net.CredentialCache.DefaultCredentials; XmlDocument xmlDoc = new System.Xml.XmlDocument(); XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", ""); XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", ""); XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", ""); ndQueryOptions.InnerXml = ""; //Query設置 ndViewFields.InnerXml = ""; //視圖設置 ndQuery.InnerXml = ""; //Caml語句 try { XmlNode ndListItems = listService.GetListItems("Test", null, ndQuery, ndViewFields, "1", ndQueryOptions, null); //獲取列表內容 Console.Write(ndListItems.OuterXml); //輸出獲取的Xml內容 } catch (System.Web.Services.Protocols.SoapException ex) { } 6、 獲取ListItem信息結果 7、 修改ListItem項
8、修改ListItem后的結果 8、 以上是幾個操作List的WebService的示例,自己也是參考微軟的示例代碼,讀取出來的信息是Xml,然后在Xml中獲取我們需要的信息就可以了。 Lists的SDK地址: http://msdn.microsoft.com/zh-cn/library/websvclists.lists_methods(v=office.12).aspx Sharepoint 可以幫助企業用戶輕松完成日常工作。 |
溫馨提示:喜歡本站的話,請收藏一下本站!