SharePoint 2007是否有可用的客户端SDK?

时间:2014-12-26 14:27:30

标签: c# sharepoint sharepoint-2010 sharepoint-2007

我们有一个SharePoint Server 2007,我们正尝试使用c#.net代码在SharePoint中创建少量条目。我开始知道我们可以使用SharePoint Client SDK组件。但是没有找到适用于2007版SharePoint的SDK。

是否可以使用SharePoint 2013 Client SDK组件访问SharePoint 2007网站并执行所有获取或更新操作?

2 个答案:

答案 0 :(得分:1)

我不知道2013 SDK是否可用于2007实例,但我知道SharePoint 2007 SDK可用here

答案 1 :(得分:0)

由于SharePoint客户端组件SDK包含客户端对象模型(CSOM)DLL的集合,并且SharePoint 2007中支持,因此SharePoint的版本适用于2007版的Client SDK。

但是您可以将SharePoint 2007 Web Services用于此目的,以下示例演示如何使用SharePoint Web服务创建列表项:

using System;
using System.Collections.Generic;
using System.Net;
using System.Xml;

namespace SharePoint.Client
{
    public class ListsClient : IDisposable
    {
        public ListsClient(Uri webUri, ICredentials credentials)
        {
            _client = new Lists.Lists();
            _client.Credentials = credentials;
            _client.Url = webUri + "/_vti_bin/Lists.asmx";
        }

        public ListsClient(Uri webUri)
        {
            _client = new Lists.Lists();
            _client.Url = webUri + "/_vti_bin/Lists.asmx";
        }


        /// <summary>
        /// Create a List Item 
        /// </summary>
        /// <param name="listName">List Name</param>
        /// <param name="propertyValues">List Item properties</param>
        /// <returns></returns>
        public XmlNode CreateListItem(string listName,Dictionary<string,string> propertyValues)
        {
            var payload = new XmlDocument();
            var updates = payload.CreateElement("Batch");
            updates.SetAttribute("OnError", "Continue");
            var method = payload.CreateElement("Method");
            method.SetAttribute("ID", "1");
            method.SetAttribute("Cmd", "New");
            foreach (var propertyValue in propertyValues)
            {
                var field = payload.CreateElement("Field");
                field.SetAttribute("Name", propertyValue.Key);
                field.InnerText = propertyValue.Value;
                method.AppendChild(field);
            }
            updates.AppendChild(method);
            return _client.UpdateListItems(listName, updates);
        }



        public void Dispose()
        {
            _client.Dispose();
            GC.SuppressFinalize(this);
        }


        protected Lists.Lists _client;  //SharePoint Web Services Lists proxy

    }
}

<强>用法

如何创建任务项:

using (var client = new SPOListsClient(webUrl, userName, password))
{
    var taskProperties = new Dictionary<string, string>();
    taskProperties["Title"] = "Order approval";
    taskProperties["Priority"] = "(2) Normal";
    var result = client.CreateListItem(listTitle, taskProperties);    
}

参考