【问题标题】:Using GetListItems with Ajax call from SharePoint 2010将 GetListItems 与来自 SharePoint 2010 的 Ajax 调用一起使用
【发布时间】:2017-07-05 13:51:53
【问题描述】:

我正在尝试编写一个 ajax 调用以使用 Lists.asmx 从 SharePoint 检索列表项

即使我正确地遵循了格式,我仍然收到302 错误。我错过了什么吗?

代码

function makeSoapCall(listName){
    var soapEnv =  
    "<?xml version='1.0' encoding='utf-8'?> " +
    "<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'> " +
        "<soap12:Body> " +
            "<GetList xmlns='http://schemas.microsoft.com/sharepoint/soap/'> " +
                "<listName>Webpostings Approvers</listName> " +
            "</GetList> " +
        "</soap12:Body> " +
    "</soap12:Envelope>";

        $.ajax({
            url: "http://webpub.ex.com/_vti_bin/Lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            contentType: "application/soap+xml; charset=utf-8"
        });
    }

回应

http://webpub.ex.com/_layouts/error.aspx?ErrorText=Request format is unrecognized.

【问题讨论】:

    标签: jquery ajax web-services sharepoint sharepoint-2010


    【解决方案1】:

    因为您需要列表项。您必须使用 Getlistitems 而不是 Getlist。

     function getSharepointListData (myList) {
    
           var listName = myList;
    
        var soapEnv =
            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>"+listName+"</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='Author' /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";
    
        $.ajax({
            url: "http:URL/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-04
      • 1970-01-01
      • 2010-11-07
      • 1970-01-01
      • 2015-09-29
      • 2011-11-16
      • 1970-01-01
      相关资源
      最近更新 更多