Я пытаюсь получить набор элементов списка из sharepoint через WebService. Я хочу запросить небольшое подмножество предметов, которые будут возвращены. Мой SOAP-пакет, похоже, упорядочен должным образом, однако, по-прежнему кажется, что служба игнорирует мой установленный фильтр (запрос). Есть идеи, почему это все еще происходит?
<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/>
<ns0:Body>
<ns1:GetListItems>
<ns1:listName>MyCalendar</ns1:listName>
<query>
<Query>
<Where>
<Eq>
<FieldRef Name="EventDate"/>
<Value Type="DateTime">[Now+2Minute(s)]</Value>
</Eq>
</Where>
</Query>
</query>
</ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>
и вот код python suds, который я использовал для создания этого мыла:
Query = Element('Query')
where = Element('Where')
eq = Element('Eq')
eq.append(Element('FieldRef').append(Attribute('Name', 'EventDate')))
vt = Element('Value').append(Attribute('Type', 'DateTime')).setText('[Now+2Minute(s)]')
eq.append(vt)
where.append(eq)
Query.append(where)
query = Element('query')
query.append(Query)
EDIT:
Вот правильный пакет мыла и код suds для того, что в итоге сработало для меня. У меня есть некоторые странные требования к фильтру, но я постараюсь опубликовать их, чтобы другие могли извлечь из этого уроки.
<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/>
<ns0:Body>
<ns1:GetListItems>
<ns1:listName>Economic Event Calendar</ns1:listName>
<ns1:query>
<Query>
<Where>
<And>
<Geq>
<FieldRef Name="EventDate"/>
<Value IncludeTimeValue="TRUE" Type="DateTime">2010-08-12T07:38:00</Value>
</Geq>
<Lt>
<FieldRef Name="EventDate"/>
<Value IncludeTimeValue="TRUE" Type="DateTime">2010-08-12T07:39:00</Value>
</Lt>
</And>
</Where>
</Query>
</ns1:query>
<ns1:rowLimit>5</ns1:rowLimit>
<viewFields>
<FieldRef Name="Description"/>
<FieldRef Name="EventDate"/>
</viewFields>
</ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>
и код python / suds, который привел меня сюда:
#craft our XML
Query = Element('Query')
where = Element('Where')
And = Element('And')
geq = Element('Geq')
geq.append(Element('FieldRef').append(Attribute('Name', 'EventDate')))
vt = Element('Value').append(Attribute('IncludeTimeValue', 'TRUE'))
vt.append(Attribute('Type', 'DateTime')).setText(convert_dt('now +' + str(alertBefore) + ' minutes', '%Y-%m-%dT%H:%M:00' ))
lt = Element('Lt')
lt.append(Element('FieldRef').append(Attribute('Name', 'EventDate')))
vt2 = Element('Value').append(Attribute('IncludeTimeValue', 'TRUE'))
vt2.append(Attribute('Type', 'DateTime')).setText(convert_dt('now +' + str((alertBefore + 1)) + ' minutes', '%Y-%m-%dT%H:%M:00' ))
#viewFields fragment, only show the Description and EventDate for returned rows
viewFields = Element('viewFields')
viewFields.append(Element('FieldRef').append(Attribute('Name','Description')))
viewFields.append(Element('FieldRef').append(Attribute('Name','EventDate')))
#pack all the XML fragments
geq.append(vt)
lt.append(vt2)
where.append(And)
And.append(geq)
And.append(lt)
Query.append(where)
query = Element('ns1:query')
query.append(Query)
#issue the query
results = c_lists.service.GetListItems(SPCal, None, query, None, 5, viewFields, None)