Lists.asmx, GetListItems eta karpetak

Ikerketa batzuk egiten ari nintzen norbaitek gaur list.asmx web zerbitzua SharePoint zati gisa emandako inguruan 2010 (eta lehenagokoak).  Gai zerrendako elementuak lortzeko erro karpeta hartan izan zen (azpi-karpetak izenak barne), baina ezin izan da azpi-karpetetako elementuak.  I did some looking around on the internets and it’s a surprisingly common question.  Oraindik, I couldn’t get a good answer to the simple question, “if I know the folder, how do I get the items in the folder?"  To be honest, I didn’t try all that hard since I’ve wanted to figure this one out on my own for a while Smile.

To set this up, I created a site named “Blogging Scenarios” and a custom list named “Custom List with Sub Folders”.  I then created folders named:

  • Year 2005
  • Year 2006
  • Year 2007

I added a few items to the folder “Year 2006”.  Hau da, zer itxura:

image

My friend isn’t writing C# code but rather using Java, so the SOAP envelope was what she really needed.  To get that, I wrote a bit of jQuery and then used fiddler to get the actual HTTP conversation.

Hemen garrantzitsua da jQuery (Kodea kopiatu dut behera nahi duzun / kopiatu itsatsi bada):

image

Dute lehen gakoa da, bai bat ere <queryOptions> eta <QueryOptions> nodoa.  Bigarren gakoa da hori <Karpeta> nodo URL bat zein bezero du sarbidea.

Ez dago beste modurik izan daiteke hori lortzeko, baina hau ongi niretzat denean jQuery erabiliz.

Hemen gainetik egiteko gutun-azala SOAP da:

<soapenv:Gutun-azal xmlns:soapenv =’http://schemas.xmlsoap.org / xaboi / gutunazal /’>                
  <soapenv:Body>
    <GetListItems xmlns =’
http://schemas.microsoft.com / SharePoint / xaboi /’>
      <Hosto erorkorreko>Azpi-karpetak zerrenda pertsonalizatua</Hosto erorkorreko>
      <viewFields>  
        <ViewFields>
          <FieldRef izena = 'Izenburua’ />
          <FieldRef izena = 'EncodedAbsUrl’ />
        </ViewFields>
      </viewFields>
      <queryOptions>
        <QueryOptions>
          <Karpeta>
http://demoserver1/Blogging Eszenatoki / zerrendak / karpetak Azpi / 2006 Urtea zerrenda pertsonalizatua</Karpeta>
        </QueryOptions>
      </queryOptions>
   
</GetListItems>
  </soapenv:Body>
</soapenv:Gutun-azal>

Adibide eta honen inguruan eztabaida handia eragin zuen, uste dut behar zela niri <QueryOptions> zehaztu eta karpeta baten izena.  Niretzat, Behar Itzulbira bai barrutik dut <queryOptions> baita zehaztu URL erabat kualifikatua <Karpeta> nodo.

Here’s the jQuery AJAX setup:

$(dokumentu).prest(funtzioa() {
       var soapEnv =
           "<soapenv:Gutun-azal xmlns:soapenv =’http://schemas.xmlsoap.org / xaboi / gutunazal /’> \
               <soapenv:Body> \
                    <GetListItems xmlns =’http://schemas.microsoft.com / SharePoint / xaboi /’> \
                       <Hosto erorkorreko>Azpi-karpetak zerrenda pertsonalizatua</Hosto erorkorreko> \
                       <viewFields> \
                           <ViewFields> \
                              <FieldRef izena = 'Izenburua’ /> \
                              <FieldRef izena = 'EncodedAbsUrl’ /> \
                          </ViewFields> \
                       </viewFields> \
                       <queryOptions> \
                         <QueryOptions> \
                           <Karpeta>http://demoserver1/Blogging Eszenatoki / zerrendak / karpetak Azpi / 2006 Urtea zerrenda pertsonalizatua</Karpeta> \
                         </QueryOptions> \
                       </queryOptions> \
                   </GetListItems> \
               </soapenv:Body> \
           </soapenv:Gutun-azal>";

</amaiera>

Nire blog Harpidetu.

Follow me on Twitter http://www.twitter.com/pagalvin

6 buruzko gogoeta "Lists.asmx, GetListItems eta karpetak

  1. Daniel

    Hi

    I am trying to display the documents under a specific folder using a SPD 2010 DataSource GetListItems

    Once I connect to to my web service and enter the guid for the document library
    I can modify the QueryOptions and enter the following piece of CAML
    Compliance Training\CompanyX.

    Only this does not return any results – removing the QueryOptions parameter returns all the documents in the root document library….

    Am I looking at passing some sort of view parameter and include the view guid.

    Erantzun
  2. Bob Bolton

    Ok, looks like it stripped out the xml… just replace the pound signs below with chevrons.

    #queryOptions#
    #QueryOptions#
    #ViewAttributes Scope=’RecursiveAll’/#
    #/QueryOptions#
    #/queryOptions#

    Erantzun
  3. Doug

    Thanks a bunch for this post, Paul. I’ve been trying to consume GetListItems via ColdFusion cfhttp, and couldn’t get the envelope right. Eventually came across this post, and your example worked flawlessly. Eskerrik asko berriro.

    Erantzun
  4. Doug

    Horretaz – do you know of a resource that lists all the proper soap envelopes? The one for GetList Items published on microsoft.com doesn’t match your here…

    Erantzun

Utzi iruzkin bat

Zure e-posta helbidea ez da argitaratuko. Beharrezko eremuak markatu dira *