SharePoint - Web服务的SOAP请求返回操作列表

时间:2016-04-07 19:41:09

标签: sharepoint soap vbscript sharepoint-2013

我有一个VB脚本,应该通过Web服务从SharePoint 2013中获取特定的列表项。

相关代码:

Dim response, request, colItem, objItem
Dim fileSystem: Set fileSystem = CreateObject("Scripting.FileSystemObject")
request = "<?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>" & _
"    <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" & _
"      <listName>{FC3E18D6-33E5-4032-BE4B-F0F92F6F18BA}</listName>" + _
"      <viewName>{2861DF9F-11F8-4E4B-A318-D4D37C1C5169}</viewName>" + _
"      <query></query>" & _
"    </GetListItems>" & _
"  </soap:Body>" & _
"</soap:Envelope>"

http.open "POST", "http://<redacted>/_vti_bin/Lists.asmx", False
http.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
http.setRequestHeader "Content-Length", Len(request)
http.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems"
http.send request

但是,如果我直接导​​航到... / _ vti_bin / Lists.asmx,这是支持的操作列表,它只返回我看到的同一页面。如果我点击&#34; GetListItems&#34;,它提供的示例XML看起来就像我在VB脚本中所拥有的那样,除了一些我认为是可选的参数:

POST /_vti_bin/Lists.asmx HTTP/1.1
Host: <redacted>
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetListItems"

<?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>
    <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>string</listName>
      <viewName>string</viewName>
      <query>string</query>
      <viewFields>string</viewFields>
      <rowLimit>string</rowLimit>
      <queryOptions>string</queryOptions>
      <webID>string</webID>
    </GetListItems>
  </soap:Body>
</soap:Envelope>

我用谷歌搜索过,无法找到我做错的事。

由于

1 个答案:

答案 0 :(得分:0)

而不是GUID尝试使用listName和viewName XML元素的列表和视图的常规名称。

 <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <listName>My List</listName>
  <viewName>All Items</viewName>
 </GetListItems>

这是我在SP 2013网站上使用jQuery的示例代码。

$.ajax({
  type: "POST",
  contentType: "text/xml; charset=utf-8",
  url: "https://site/_vti_bin/Lists.asmx",
  data: '<?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> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>My Test Cases</listName>  </GetListItems> </soap:Body> </soap:Envelope>',
  dataType: "xml",
  success: function (msg) {
   console.log(msg);
  },
  error: function (data, status, error) {
   console.log('error');
  }
  });
相关问题