List Operation

This service lists the contents of the specified folder or report unit. The following sample request lists the contents of the
/ContentFiles folder in the repository:

<request operationName="list" locale="en">
  <resourceDescriptor name="" wsType="folder" uriString="/ContentFiles"   isNew=
    "false">
    <label>null</label>
  </resourceDescriptor>
</request>

Sample response:

<operationResult version="1.2.0">
  <returnCode>0</returnCode>
  <resourceDescriptor name="html" wsType="folder" uriString="/ContentFiles/html" 
    isNew="false">
    <label>html</label>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.Folder</value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
      <value>/ContentFiles</value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION">
      <value>0</value>
    </resourceProperty>
  </resourceDescriptor>
  <resourceDescriptor name="pdf" wsType="folder" uriString="/ContentFiles/pdf" 
    isNew="false">
  <label>pdf</label>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.Folder</value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
      <value>/ContentFiles</value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION">
      <value>0</value>
    </resourceProperty>
  </resourceDescriptor>
  <resourceDescriptor name="xls" wsType="folder" uriString="/ContentFiles/xls" 
    isNew="false">
    <label>xls</label>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.Folder</value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
      <value>/ContentFiles</value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION">
      <value>0</value>
    </resourceProperty>
  </resourceDescriptor>
</operationResult>

When it lists a folder, the repository web service returns a set of resource descriptors: one for each resource that resides in the specified folder. Use / as the URI of the root folder.

Similarly, when it lists a report unit, the repository web service returns a set of resource descriptors that contain (at a minimum) the main JRXML source file. Since a resource in a report unit can be either a local resource or a reference to another repository resource, you should keep a few details in mind:

If a report unit data source is not defined locally, its wsType is set to datasource, which does not indicate the exact nature of the resource. Its type should simply be reference, but since the data source used by the report unit is a special child resource, it’s easy to recognize. The URI of the referenced resource is available in the PROP_REFERENCE_URI property.
The main JRXML resource’s wsType is always set to jrxml, even if it’s a reference to an external JRXML resource. By looking at the PROP_IS_REFERENCE and PROP_REFERENCE_URI properties, you can determine where the resource is actually stored. The PROP_RU_IS_MAIN_REPORT property identifies the main JRXML source file of the report unit, even if the order of its children is altered.
The purpose of listing a report unit is to get the list of the resources contained in the report unit. To retrieve the entire report unit (report unit resource as well as its children) at the same time, use the get service.

The following Java sample illustrates wsclient as an instance of com.jaspersoft.jasperserver.irplugin.wsclient.WSClient:

ResourceDescriptor rd = new ResourceDescriptor();
rd.setWsType( ResourceDescriptor.TYPE_FOLDER );
rd.setUriString("/");
List lst = wsclient.list(rd);

PHP sample:

$result = ws_list("/");
if (get_class($result) == 'SOAP_Fault')
{
  $errorMessage = $result->getFault()->faultstring;
}
else
{
  $folders = getResourceDescriptors($result);
}

This PHP sample uses the client.php file found in the PHP sample provided with JasperReports Server. This file defines the most important constants you may find useful when integrating with the JasperReports Server web services, as well as useful functions that wrap the list, get, and the runReport operations.

The list operation also provides a shortcut to get the list of all resources of a given type in the repository, for example all the reports. This use of the list operation has the following syntax:

<request operationName="list">
  <argument name="LIST_RESOURCES"/>
  <argument name="RESOURCE_TYPE">reportUnit</argument>
  <argument name="PARENT_DIRECTORY">/reports</argument>
</request>
<span class="Italics">or</span>
<request operationName="list">
  <argument name="LIST_RESOURCES"/>
  <argument name="RESOURCE_TYPE">reportUnit</argument>
  <argument name="START_FROM_DIRECTORY">/reports</argument>
</request>

No value is needed for the LIST_RESOURCES argument. The value of the RESOURCE_TYPE argument can be any value of wsType except folder. The PARENT_DIRECTORY argument is the name of folder in which you want to look for resources. If you want to look for the resources in a branch of the repository, use the START_FROM_DIRECTORY argument.

Using LIST_RESOURCES is the only case in which a request doesn’t require a resource descriptor.

Several Java methods in com.jaspersoft.jasperserver.irplugin.wsclient.WSClient use LIST_RESOURCES:

list(String xmlRequest) - Sends any custom request, including one using LIST_RESOURCES as shown above.
listResources(String type) - Lists all resources of the given type in the repository visible to the logged in user.
listResourcesInFolder(String type, String parentFolder) - Lists resources of the given type in the folder.
listResourcesUnderFolder(String type, String ancestorFolder) - Lists resources of the given type in the folder and the entire tree beneath that folder.
Version: 
Feedback