SharePoint List.getListItems WebService 用于递归返回子文件夹内容

10
我正在使用CXF调用lists.asmx webservice。以下的soap调用没有返回列表子文件夹中的文件。它只返回folder1、folder2和file1.pdf。

I am calling the lists.asmx webservice from CXF. The following soap call does not return files from list sub folders. It returns folder1,folder2 and file1.pdf

Shared Documents
  folder1
     file2.docx
     file3.pdf
  folder2
     sub-folder1
        file5.pdf
     file4.pdf
  file1.pdf

SOAP调用

POST /_vti_bin/lists.asmx HTTP/1.1 Accept-Encoding: gzip,deflate

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soap1="http://schemas.microsoft.com/sharepoint/soap/">
   <soap:Header/>
   <soap:Body>
      <soap1:GetListItems>
         <soap1:listName>Shared Documents</soap1:listName>
       <queryOptions> 
        <QueryOptions> 
           <IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>
           <ViewAttributes Scope="RecursiveAll"/>
           <DateInUtc>TRUE</DateInUtc>               
        </QueryOptions>
      </queryOptions> 
      </soap1:GetListItems>
   </soap:Body>
</soap:Envelope>
有没有关于如何在结果中包含folder1、folder3和sub-folder1文件的线索?如果Lists Web服务无法实现,是否有替代的服务或方法? 额外信息: 还有另一个Web服务SiteData (_vti_bin/sitedata.asmx)。它有一个类似的方法(getListItems),只返回具有列表名称而没有其他参数的所有文件。问题是我无法弄清楚如何/在哪里指定分页参数,因为它没有像List Web服务中的queryOptions输入元素。
 <soap1:strListName>?</soap1:strListName>
 <soap1:strQuery>?</soap1:strQuery>
 <soap1:strViewFields>?</soap1:strViewFields>
 <soap1:uRowLimit>?</soap1:uRowLimit>
2个回答

14

可以使用<ViewAttributes Scope="RecursiveAll"/>元素递归获取列表内容。 我的SOAP信封中有一个愚蠢的错误。queryOptions元素没有命名空间。我在下面的文本中进行了修复。

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soap1="http://schemas.microsoft.com/sharepoint/soap/">
   <soap:Header/>
   <soap:Body>
      <soap1:GetListItems>
         <soap1:listName>Shared Documents</soap1:listName>
       <**soap1:**queryOptions> 
        <QueryOptions> 
           <IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>
           <ViewAttributes Scope="RecursiveAll"/>
           <DateInUtc>TRUE</DateInUtc>               
        </QueryOptions>
      </**soap1:**queryOptions> 
      </soap1:GetListItems>
   </soap:Body>
</soap:Envelope>

顺便说一下,有一个很棒的工具,U2U CAML Builder 可以用来构建SharePoint CAML查询语句。我真希望几周前就发现了它。


当我添加 soap1: 行时,我收到响应代码:400,响应消息:错误请求。我是否遗漏了什么? - Abhay Chaware
我尝试使用相同的请求来获取给定列表中所有文件夹和文件,但它只给了我顶级文件和文件夹。有什么建议吗? - Vijay Kumar

3

谢谢。问题在上面的SOAP信封中。 - so_mv

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接