1.1 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:
|
Sample response:
|
|
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
wsTypeis set todatasource, which does not indicate the exact nature of the resource. Its type should simply bereference, 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 thePROP_REFERENCE_URIproperty. -
The main JRXML resource’s
wsTypeis always set tojrxml, even if it’s a reference to an external JRXML resource. By looking at thePROP_IS_REFERENCEandPROP_REFERENCE_URIproperties, you can determine where the resource is actually stored. ThePROP_RU_IS_MAIN_REPORTproperty 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
getservice.The following Java sample illustrates
wsclientas an instance ofcom.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>or <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_RESOURCESargument. The value of theRESOURCE_TYPEargument can be any value ofwsTypeexceptfolder. ThePARENT_DIRECTORYargument 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 theSTART_FROM_DIRECTORYargument.Note
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.WSClientuseLIST_RESOURCES: -
list(String xmlRequest)- Sends any custom request, including one usingLIST_RESOURCESas 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.