Lists.asmx, GetListItems u folders

I kienet tagħmel xi riċerka għal xi ħadd illum madwar id-servizz web list.asmx pprovduta bħala parti mill SharePoint 2010 (u qabel).  Hija kienet kapaċi tikseb l-oġġetti lista fil-folder għerq (inklużi l-ismijiet tas-sub-folders), iżda ma setgħux jiksbu oġġetti f'sub-folders.  I ma xi tfittex madwar fuq il-internets u huwa kwistjoni sorprendentement komuni.  Madankollu, I ma setgħux jiksbu risposta tajba għall-mistoqsija sempliċi, "Jekk Naf li l-folder, kif nista 'nikseb l-oġġetti fil-folder?"  Biex inkun onest, I ma tipprova kollu li diffiċli peress stajt riedu figura dan wieħed fuq tiegħi stess għal waqt Tbissem.

Biex jistabbilixxu dan up, I ħolqot sit jismu "Xenarji Blogging" u lista tad-dwana bl-isem "Lista Custom mal folders Sotto".  I imbagħad maħluqa folders msemmija:

  • Sena 2005
  • Sena 2006
  • Sena 2007

I miżjuda ftit punti għall-folder "Sena 2006".  Dan huwa dak li jidher qisu:

image

My friend ma jkunx miktub C # kodiċi iżda pjuttost jużaw Java, sabiex il-pakkett SAPUN kien dak li hi verament meħtieġ.  Biex tikseb li, I kiteb daqsxejn ta 'jQuery u mbagħad użata fiddler biex jiksbu l-konversazzjoni HTTP attwali.

Hawn il-jQuery rilevanti (I kkupjati-kodiċi stabbiliti hawn taħt jekk inti tixtieq li kopja / paste):

image

Huma l-ewwel importanti hu li jinkludu kemm <queryOptions> u <QueryOptions> node.  It-tieni muftieħ huwa li l- <Folder> node huwa URL li l-klijent ikollu aċċess.

Jista 'jkun hemm modi oħra biex tikseb dan, iżda dan ħadem tajjeb għalija meta jużaw jQuery.

Hawn hu l-pakkett SAPUN għal dan t'hawn fuq:

<soapenv:Xmlns Pakkett:soapenv =’http://schemas.xmlsoap.org / sapun / pakkett /’>                
  <soapenv:Korp>
    <Xmlns GetListItems =’
http://schemas.microsoft.com / Sharepoint / sapun /’>
      <Jwaqqgħu l-weraq>Lista Custom mal folders Sotto</Jwaqqgħu l-weraq>
      <viewFields>  
        <ViewFields>
          <FieldRef Isem = "Titolu’ />
          <FieldRef Isem = "EncodedAbsUrl’ />
        </ViewFields>
      </viewFields>
      <queryOptions>
        <QueryOptions>
          <Folder>
http://demoserver1/Blogging Xenarji / listi / Lista Custom mal folders Sotto / Sena 2006</Folder>
        </QueryOptions>
      </queryOptions>
   
</GetListItems>
  </soapenv:Korp>
</soapenv:Envelop>

A lott ta 'eżempji u diskussjoni madwar dan wasslitni biex jemmnu li kollha I bżonn kien <QueryOptions> u tispeċifika isem folder.  Għalija, I-ħtieġa li kemm wrap dan ġewwa <queryOptions> kif ukoll tispeċifika URL ikkwalifikat bis-sħiħ għall- <Folder> node.

Hawn il-setup Ajax jQuery:

$(dokument).lest(funzjoni() {
       kien soapEnv =
           "<soapenv:Xmlns Pakkett:soapenv =’http://schemas.xmlsoap.org / sapun / pakkett /’> \
               <soapenv:Korp> \
                    <Xmlns GetListItems =’http://schemas.microsoft.com / Sharepoint / sapun /’> \
                       <Jwaqqgħu l-weraq>Lista Custom mal folders Sotto</Jwaqqgħu l-weraq> \
                       <viewFields> \
                           <ViewFields> \
                              <FieldRef Isem = "Titolu’ /> \
                              <FieldRef Isem = "EncodedAbsUrl’ /> \
                          </ViewFields> \
                       </viewFields> \
                       <queryOptions> \
                         <QueryOptions> \
                           <Folder>http://demoserver1/Blogging Xenarji / listi / Lista Custom mal folders Sotto / Sena 2006</Folder> \
                         </QueryOptions> \
                       </queryOptions> \
                   </GetListItems> \
               </soapenv:Korp> \
           </soapenv:Envelop>";

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

6 ħsibijiet dwar "Lists.asmx, GetListItems u folders

  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.

    1. Paul Galvin awtur Post

      This is a very old post/comment so sorry for never replying. I assume you long since figured out how to proceed.

  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#

  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. Grazzi għal darb'oħra.

  4. Doug

    BTW – 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…

Ħalli Irrispondi

Your email address mhux se jkun ippubblikat. Meħtieġa oqsma huma mmarkati *