【发布时间】:2016-05-26 13:56:30
【问题描述】:
我有 2 个 Sharepoint 2013 网站。 当用户在第一个 SPSite -> 启动工作流时在 SPList 中添加新项目时,必须在第二个 SPSite 的 SPList 中添加项目副本。这是我的代码:
public void UpdateSPList(string Title)
{
using (AuthenticationSvc.Authentication authSvc = new AuthenticationSvc.Authentication())
{
try
{
using (ListsSvc.Lists list = new ListsSvc.Lists())
{
list.Url = @"http://second-srharepoint-site.com/_vti_bin/Lists.asmx";
list.CookieContainer = new System.Net.CookieContainer();
list.AllowAutoRedirect = true;
list.PreAuthenticate = true;
list.Credentials = new System.Net.NetworkCredential("domain\\username", "password");
string strBatch = "<Method Cmd='New'><Field Name='Title'>" + Title + "</Field> ";
XmlDocument xmlDoc = new XmlDocument();
XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
elBatch.InnerXml = strBatch;
XmlNode ndReturn = list.UpdateListItems("SPListName", elBatch);
}
}
finally
{
}
}
}
但是在线elBatch.InnerXml = strBatch;我得到异常:
- $exception {“文件意外结束。以下元素未关闭:方法。第 1 行,位置 60。”} System.Exception {System.Xml.XmlException}
我不知道如何解决这个问题。请帮帮我。
【问题讨论】:
-
XML 字符串无效。您需要为 all 元素添加结束元素,而不仅仅是最后一个
-
你为什么不使用 CSOM 呢?您可以像使用任何其他 ORM 或 OData 客户端一样简单地更新 Name Title 属性。 asmx 网络服务早在 2010 年就被弃用了,所以你的代码从定义上来说是有问题的。
-
不知道怎么做比较好。
标签: c# sharepoint workflow sharepoint-2013 sharepoint-workflow