jquery - 使用 JQuery 通过 sharepoint Web 服务删除文档

标签 jquery web-services sharepoint

如果有人上传文档然后点击取消,我会尝试使用共享点网络服务删除文档。我创建了以下函数

    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 - Invalid file name

The file name you specified could not be used. It may be the name of an existing file or directory, or you may not have permission to access the file.

有谁知道为什么这可能会失败。我正在针对标准文档库运行代码。

我已经针对 checkin 和 checkout 的文件进行了尝试,并得到了相同的消息。我需要这个来针对已 checkout 的文档运行,事实上它们永远不会被 checkin ,所以我不知道如何计算出 fileref

最佳答案

对于文档,您还需要包含 FileRef

<Field Name="FileRef">http://Server/[sites/][Site/]Library/File</Field>

关于jquery - 使用 JQuery 通过 sharepoint Web 服务删除文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3188121/

相关文章:

java - Angular 4.1 使用 springboot webservices 进行基本身份验证

c# - 不使用 try/catch 自动记录未处理的异常

asp.net - 使用基于表单的身份验证时,是否可以与sharepoint 2010共享现有的asp.net应用程序成员数据库

jquery - Jackson 无法读取文档 : Unrecognized token 'contactForm' : was expecting ('true' , 'false' 或 'null' )

javascript - 如何让相对位置像 iPhone 上的固定位置一样工作?

javascript - 查找以变量结尾的元素

php - 引导表在大量记录上加载时间较长

php - 在服务模块中为 REST 服务器启用 SSL 时没有返回数据

java - 基于非 HTTP 协议(protocol)的 SOAP

c# - 在 Sharepoint 中按组获取用户