繁体   English   中英

如何使用SOAP从Sharepoint列表接收GetListItems?

[英]How Can I receive the GetListItems from Sharepoint List using SOAP?

我需要从SharePoint列表中获取列表项。

我在本地做。 我尝试使用此代码:

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>

    $(document).ready(function() {
        var listName = "Backlog";
        makeSoapCall(listName);
    });

function makeSoapCall(listName){
    var soapEnv =
    "<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> \
        <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
          <listName>" + listName + "</listName> \
          <viewName></viewName> \
          <query></query> \
          <viewFields></viewFields> \
          <rowLimit></rowLimit> \
          <queryOptions></queryOptions> \
          <webID></webID> \
        </GetListItems> \
      </soap:Body> \
    </soap:Envelope>"

  $.ajax({
    url: "http://server/site/_vti_bin/Lists.asmx",
    type: "POST",
    dataType: "jsonp",
    data: soapEnv,
    complete: resultsFeedback,
    contentType: "application/json; charset=\"utf-8\""
  });

}

function resultsFeedback(xData, status) {
    console.log("xData: " + xData);
    console.log("status: " + status);
}

然后,我收到此消息:

Resource interpreted as Script but transferred with MIME type text/html: "http://server/site/_vti_bin/Lists.asmx?callback=jQuery11100353987290…stItems%3E%20%20%20%3C/soap:Body%3E%20%3C/soap:Envelope%3E&_=1396538736189". jquery-1.11.0.min.js:4 Uncaught SyntaxError: Unexpected token < Lists.asmx:3

xData: [object Object] report.html:37
status: parsererror

有人可以帮忙吗?

提前致谢。 埃德森·马丁斯

您的ajax调用对象的数据类型属性不正确。 它应该是“ xml”。 另外,您的“ contentType”属性应具有application / xml值而不是json。请尝试以下操作:

$.ajax({
    url: "http://server/site/_vti_bin/Lists.asmx",
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    complete: resultsFeedback,
    contentType: "application/xml; charset=\"utf-8\""
  });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM