2011-02-16 78 views
-1

嘗試通過SOAP將Python與Sharepoint交談。Sharepoint/SOAP - GetListItems忽略查詢

我試圖查詢的其中一個列表包含'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返回的所有項目從列表中完全無視查詢來查詢列表項。

有什麼想法?

回答

2

的實際結果是,有必要在這裏使用

<ns1:query> 

(無論何種原因)。

0

Try 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> 
+0

也不會影響以下代碼:http://pastie.org/1570201 – 2011-02-16 12:00:17

+0

如果您使用類似U2U CAML查詢生成器(http://www.u2u.net/Tools/wincamlquerybuilder)會發生什麼情況/CamlQueryBuilder.aspx)執行相同的查詢? – 2011-02-16 12:21:49