I now solved it by using the Client Object Model (as Doug suggested). Uploading a file using the COM is pretty simple:
public void UploadXmlFile(string xmlContent, int orderNumber)
{
string filename = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + "_" + orderNumber + ".xml";
ClientContext context = new ClientContext(absoluteHostUrl + relativeWebUrl);
using (MemoryStream stream = new MemoryStream())
{
// use a MemoryStream for the file contents
StreamWriter writer = new StreamWriter(stream);
writer.Write(xmlContent);
writer.Flush();
stream.Position = 0;
// ... and upload it.
Microsoft.SharePoint.Client.File.SaveBinaryDirect(
context,
"/" + relativeWebUrl + "Lists/" + libraryName + "/" + filename,
stream,
false);
}
// ...
... but after uploading the file is checked-out, and I still have to set my integer column:
// ...
// get the created entry
Web web = context.Web;
List list = web.Lists.GetByTitle(libraryName);
ListItemCollection itemCol = list.GetItems(new CamlQuery() { ViewXml = "<View/>" });
context.Load(itemCol,
items => items
.Include(i => i[COLUMN_IMPORTORDERNUMBER])
.Where(i => (string)i[COLUMN_FILELEAFREF] == filename)
.Take(1)
);
context.ExecuteQuery();
// ... found it? ...
if (itemCol != null && itemCol.Count > 0)
{
ListItem item = itemCol[0];
// ... set the ImportOrderNumber
item[COLUMN_IMPORTORDERNUMBER] = orderNumber;
item.Update();
// ... and check in
item.File.CheckIn("Checked in by WebService", CheckinType.MajorCheckIn);
context.ExecuteQuery();
}
}