簡體   English   中英

如何以編程方式在Sharepoint中創建一個wiki頁面(= item)?

[英]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上傳文檔,我還沒弄清楚如何重命名文檔。

Dan Winter編寫了一個很棒的應用程序,我認為可以提供一些示例代碼,請在此處查看:

WikiMigrator

或者有關更多信息,請閱讀他的綜合博客文章

如果沒有其他工作,您應該開發自己的Web服務來提供此功能。 開箱即用的選項在功能方面是眾所周知的,但沒有什么能阻止你添加它們。

我會將Nat的解決方案包裝到Web服務代碼中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM