When the PropertyCollector returns array data representing an array of managed objects, the array has the type xsd:anyType. To use the data in your application, you must first cast it to a specialized type for arrays of managed object references.
This example code uses the JAX-WS-generated Java bindings for the VMware vSphere Web Services SDK WSDL.
Procedure
- Use the DynamicProperty.getVal() method to retrieve the
anyType
property value. - Cast the anyType value to a value of type ArrayOfManagedObjectReference.
- Use the corresponding get method to assign the result of the cast operation to a list variable.
Example
/* * Handling arrays of ManagedObjectReference objects. * Cast the return value to ArrayOfManagedObjectReference and use getManagedObjectReference(). */ List[] morList = ((ArrayOfManagedObjectReference)dynamicProp.getVal()).getManagedObjectReference();