我想刪除文檔,使用sharepoint webservice,如果有人上傳文檔然後點擊取消。我創建了以下功能使用JQuery通過Sharepoint Web服務刪除文檔
function DeleteDocument(libraryName, ID)
{
debug.log('DeleteDocument (Entry) libraryname = '+libraryName+' ID='+ID);
var batch =
"<Batch OnError='Continue'> \
<Method ID='1' Cmd='Delete'> \
<Field Name='ID'>" + ID + "</Field> \
</Method> \
</Batch>";
var soapEnv =
"<?xml version='1.0' encoding='utf-8'?> \
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' \
xmlns:xsd='http://www.w3.org/2001/XMLSchema' \
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
<soap:Body> \
<UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>"+libraryName+"</listName> \
<updates> \
" + batch + "</updates> \
</UpdateListItems> \
</soap:Body> \
</soap:Envelope>";
debug.log(soapEnv);
$.ajax({
url: "http://<serverandsite>/_vti_bin/lists.asmx",
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction",
"http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
},
type: "POST",
dataType: "xml",
data: soapEnv,
complete: function(xData, status){
alert(xData.responseText);
debug.log('xData response = ' + xData.responseText);
debug.log('status response = ' + status);
},
contentType: "text/xml; charset=utf-8"
});
}
當我運行它,我得到
0x81020030 - 文件名無效
您指定的文件名不能 使用。它可能是 現有文件或目錄的名稱,或者您可能 無權訪問 文件。
有沒有人有任何想法,爲什麼這可能會失敗。我正在針對標準文檔庫運行代碼。
我已經嘗試過對付簽入和簽出文件並獲得相同的消息。我需要這對已簽出的文檔上運行,事實上,他們永遠不會被檢查的,所以我不知道我怎麼會制定出fileref
剛剛添加我剛剛試圖強制一個元素,這會產生相同的錯誤 –
Buzzby
2010-07-06 16:31:07