如何以编程方式在 Sharepoint 中创建 wiki 页面 (=item)?

发布于 2024-07-24 23:40:13 字数 567 浏览 4 评论 0原文

如何创建 wiki 页面并添加标题以及 sharepoint 中的一些内容(通过网络服务)?

这是到目前为止我的 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>

它创建了一个新页面,但没有内容也没有标题。

how do I create a wiki page and add a title, as well as some content in sharepoint (via webservices)?

This is my SOAP message so far:

  <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>

It creates a new page, but it has no content and no title.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回梦 2024-07-31 23:40:13

获取 SharePoint Manager 的副本,它可以向您显示大量有趣的信息。

您需要名称字段(它包括“.aspx”)。
标题字段在 wiki 中不相关(空白),页面按其名称进行索引。

--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。
注意:我还没有弄清楚如何在使用网络服务上传文档后对其进行重命名。

Grab a copy of SharePoint Manager it can show you heaps of interesting info.

you want the Name field (it includes the ".aspx").
The title field is not relevant in a wiki (blank), pages are indexed by thier name instead.

--update--

Using the copy.asmx allows you to upload a new document. The template page is a page that has been downloaded previously (it stores no information, equivalent to a layout page).

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);

}

Then you can call the lists.asmx to update the wikifield.
Note: I have not figure out how to rename a document once it has been uploaded using webservices.

飘逸的'云 2024-07-31 23:40:13

如果其他方法都不起作用,您应该开发自己的 Web 服务来提供此功能。 众所周知,开箱即用的选项在功能上受到限制,但没有什么可以阻止您添加它们。

我会包装Nat的解决方案 进入网络服务代码。

If nothing else is working you should develop your own web service to provide this feature. The out-of-the-box options are notoriously limited in functionality but there is nothing stopping you from adding to them.

I would wrap Nat's solution into the web service code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文