2010-08-10 4 views
2

WebService를 통해 셰어 포인트에서 목록 항목 집합을 가져 오려고합니다. 내가 반환 할 항목의 작은 하위 집합을 쿼리하고 싶습니다. 내 SOAP 패킷이 제대로 정렬 된 것으로 보이지만 서비스에서 내 설정된 필터 (쿼리)를 무시하고있는 것처럼 보입니다. 왜 아직도 이런 일이 벌어지고있는가?목록 항목 (GetListItems)의 셰어 포인트 필터

<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> 

여기에 내가이 비누를 생성하는 데 사용 파이썬 비눗물 코드 :

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) 

편집 : 여기

결국 나를 위해 일한 무엇에 대한 적절한 비누 패킷 비눗물 코드 . 필터 주위에 이상한 요구 사항이 있지만 다른 사람들이이 사실을 알 수 있도록 앞으로 게시 할 예정입니다.

<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> 

여기에 저를 얻었다 파이썬/비눗물 코드 :

#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) 

답변

1

당신의 Value 요소에 IncludeTimeValue 속성을 사용해보십시오 :

<Value Type="DateTime" IncludeTimeValue="TRUE">[Now+2Minute(s)]</Value> 

따르면 MSDN에 :

IncludeTimeValue : 선택적 Boolean입니다. 시간뿐만 아니라 날짜를 기반으로하는 DateTime 쿼리를 작성하도록 지정합니다. 이 속성을 설정하지 않으면 날짜 및 시간과 관련된 조회의 시간 부분이 무시됩니다.

나는 CAML 쿼리에 많은 DateTime 필터를 사용하지 않았지만 SOAP 패킷에 대한 모든 내용이 정확합니다.

+0

CBono, 바로 당신이 선생님입니다! 나는 이것을 게시 한 후 몇 시간 후에이 것을 알아 냈습니다. U2U의 CAML 생성기 덕분에이 문제에 많은 도움이되었습니다. 답변 해 주셔서 감사합니다. – nnachefski

+1

네, CAML Builder는 SP 개발자를위한 필수 유틸리티입니다. – CBono