簡體   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