4

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.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Stefan
  • 28,843
  • 15
  • 64
  • 76
  • 1
    Do you have permissions to create your own web service on the SharePoint server? If that's the case then you have access to the entire SharePoint object model for creating your wiki page. I might be able to cobble up some sample code for you if this is indeed an option for you. – Philipp Schmid Jun 17 '09 at 21:31
  • Sadly it's not an option to write my own web service, because the solution has to work on generic Sharepoint servers. – Stefan Jun 18 '09 at 15:03

2 Answers2

4

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.

Nat
  • 14,175
  • 5
  • 41
  • 64
1

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.

Community
  • 1
  • 1
Alex Angas
  • 59,219
  • 41
  • 137
  • 210
  • Sadly it's not an option to write my own web service, because the solution has to work on generic Sharepoint servers. – Stefan Jun 18 '09 at 15:04