【问题标题】:Sharepoint/SOAP - GetListItems ignoring querySharepoint/SOAP - GetListItems 忽略查询
【发布时间】:2011-02-16 11:05:16
【问题描述】:

尝试通过 SOAP 从 Python 与 Sharepoint 对话。

我尝试查询的列表之一包含“ID”作为主键字段。

(Field){
   _RowOrdinal = "0"
   _FromBaseType = "TRUE"
   _DisplayName = "ID"
   _Name = "ID"
   _SourceID = "http://schemas.microsoft.com/sharepoint/v3"
   _ColName = "tp_ID"
   _StaticName = "ID"
   _PrimaryKey = "TRUE"
   _ReadOnly = "TRUE"
   _Type = "Counter"
   _ID = "{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}"
},

我们发送以下请求来查询 ID=77 的列表项

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:GetListItems>
         <ns1:listName>60e3f442-6faa-4b49-814d-2ce2ec88b8d5</ns1:listName>
         <query><Query><Where>
            <Eq>
               <FieldRef Name="ID"/>
               <Value Type="Counter">77</Value>
            </Eq>
         </Where></Query></query>
       </ns1:GetListItems>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

但是,Sharepoint 完全忽略查询返回列表中的所有项目。

有什么想法吗?

【问题讨论】:

    标签: python sharepoint soap


    【解决方案1】:

    实际证明是必须要使用的

    <ns1:query> 
    

    在这里(无论出于何种原因)。

    【讨论】:

    • 基本上,query 是 webservice API 的一部分(它是服务的参数),所以如果它不在 API 类型的命名空间中(由 http://schemas.microsoft.com/sharepoint/soap/ 定义),它将是默认命名空间的一种类型,因此不会被服务识别。
    • 注意:如果您使用的是 suds 0.4+,您可能需要使用 this ticket 中详述的更改修补 suds/mx/appender.py 这也包括 suds-jurko 0.6+
    【解决方案2】:

    尝试使用 Type="Number" 而不是 Counter。我刚刚完成了我不久前编写的一堆代码,以根据 ID 获取列表项,并且我使用了 Number,它可以工作。

    您可能还需要包含视图和内容的空元素。以下是我生成的请求的片段:

     <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>Workgroups</listName>
      <viewName />
      <query><Query>
       <Where><Eq><FieldRef Name="ID"/><Value Type="Number">101</Value></Eq></Where>
      </Query></query>
      <viewFields><ViewFields><FieldRef Name="Title"/><FieldRef Name="Leader" /><FieldRef Name="Members" /><FieldRef Name="hiddenmembers" /></ViewFields></viewFields>
      <rowLimit />
      <queryOptions><QueryOptions /></queryOptions>
     </GetListItems>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多