How to retrieve the size of a file in a document library in sharepoint through webservices using Java

StackOverflow https://stackoverflow.com/questions/15831063

Frage

I'm writting an application in Java which has to report all available files in a document library on SharePoint 2007. The application uses the java sharepoint library from korecky (Project Home). Everything works fine except for the fact, that beside of several file information I don't get the file size.

Concretely, a request is send to the List.asmx webservice calling the GetListItems method.

The request looks as follows:

<QueryOptions>
    <ViewAttributes IncludeRootFolder="True" Scope="RecursiveAll"/>
    <IncludeMandatoryColumns>
        TRUE
    </IncludeMandatoryColumns>
    <DateInUtc>
        TRUE
    </DateInUtc>
</QueryOptions>

According to several forums in the response from the webservice there should be an field available named ows_File_x0020_Size that should contain an int representing the file size, but it is missing. Does anybody have an idea how the request needs to be modified to also receive the file size?

War es hilfreich?

Lösung

You need to say the field you want to call (in the ViewFields). The final request should look like this :

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>My Documents List</listName>
      <viewName></viewName>
      <query><Query></Query></query>
      <viewFields>
        <ViewFields Properties="True">
          <FieldRef Name="FileLeafRef"></FieldRef>
          <FieldRef Name="File_x0020_Size"></FieldRef>
        </ViewFields>
      </viewFields>
      <rowLimit>0</rowLimit>
      <queryOptions>
        <QueryOptions>
          <DateInUtc>True</DateInUtc>
          <Paging ListItemCollectionPositionNext=""></Paging>
          <ViewAttributes Scope="Recursive"></ViewAttributes>
          <IncludeAttachmentUrls>True</IncludeAttachmentUrls>
          <IncludeMandatoryColumns>False</IncludeMandatoryColumns>
          <ExpandUserField>False</ExpandUserField>
        </QueryOptions>
      </queryOptions>
    </GetListItems>
  </soap:Body>
</soap:Envelope>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top