[英]How to create a wiki page (=item) in Sharepoint programmatically?
如何创建Wiki页面并添加标题,以及sharepoint中的一些内容(通过webservices)?
到目前为止,这是我的SOAP消息:
<soapenv:Body>
<soap:UpdateListItems>
<soap:listName>Cooking Wiki</soap:listName>
<soap:updates>
<Batch OnError="Continue">
<Method ID="1" Cmd="New">
<Field Name="WikiField">Mix two eggs and a cup of milk.</Field>
</Method>
</Batch>
</soap:updates>
</soap:UpdateListItems>
</soapenv:Body>
它会创建一个新页面,但它没有内容,也没有标题。
获取SharePoint Manager的副本,它可以显示大量有趣的信息。
你想要名字字段(它包括“.aspx”)。 标题字段与维基(空白)无关,页面由其名称索引。
--update--
使用copy.asmx可以上传新文档。 模板页面是先前已下载的页面(它不存储任何信息,相当于布局页面)。
private byte[] GetTemplatePage()
{
FileStream fs = new FileStream("templatePage.aspx", FileMode.Open);
byte[] fileContents = new byte[(int)fs.Length];
fs.Read(fileContents, 0, (int)fs.Length);
fs.Close();
return fileContents;
}
private void UploadDoc(string pageName)
{
byte[] wikiBytes = GetTemplatePage();
string dest = "http://[website]/wiki/Wiki%20Pages/" + pageName + ".aspx";
string[] destinationUrlArray = new string[] { dest };
IntranetCopy.Copy copyService = new IntranetCopy.Copy();
copyService.UseDefaultCredentials = true;
copyService.Url = "http://[website]/wiki/_vti_bin/copy.asmx";
IntranetCopy.FieldInformation fieldInfo = new IntranetCopy.FieldInformation();
IntranetCopy.FieldInformation[] fields = { fieldInfo };
IntranetCopy.CopyResult[] resultsArray;
copyService.Timeout = 600000;
uint documentId = copyService.CopyIntoItems(dest, destinationUrlArray, fields, wikiBytes, out resultsArray);
}
然后你可以调用lists.asmx来更新wikifield。 注意:一旦使用webservices上传文档,我还没弄清楚如何重命名文档。
看看这个页面:
如果没有其他工作,您应该开发自己的Web服务来提供此功能。 开箱即用的选项在功能方面是众所周知的,但没有什么能阻止你添加它们。
我会将Nat的解决方案包装到Web服务代码中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.