0
我想創建一個返回SharePoint ListCollection的WCF服務。我已經用下面的代碼嘗試:如何序列化Microsoft.SharePoint.Client.ListItem(Sharepoint-2013)?
public class Service1 : IService1
{
public ListItemCollection GetList()
{
string username = "xxx";
string userPassword ="xxx";
var securePassword = new SecureString();
for (int i = 0; i < userPassword.Length; i++)
{
securePassword.AppendChar(userPassword[i]);
}
var creds = new SharePointOnlineCredentials(username, securePassword);
var clientContext = new ClientContext("MySharepointurl");
clientContext.Credentials = creds;
List announcementsList = clientContext.Web.Lists.GetByTitle("mylist");
CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
var items = announcementsList.GetItems(query);
clientContext.Load(items);
clientContext.ExecuteQuery();
return items;
}
}
但它像下面給我的錯誤:
類型「Microsoft.SharePoint.Client.ListItem」不能被序列化。考慮使用DataContractAttribute屬性標記它,並使用DataMemberAttribute屬性標記要序列化的所有成員。如果類型是一個集合,請考慮使用CollectionDataContractAttribute來標記它。有關其他支持的類型,請參閱Microsoft .NET Framework文檔。