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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With