Solaris WBEM Developer's Guide

Calling Methods

You use the invokeMethod interface to call a method in a class supported by a provider. To retrieve the signature of a method, an application must first get the definition of the class to which the method belongs. The invokeMethod method returns a CIMValue. The return value is null when the method that you invoke does not define a return value.

The invokeMethod interface takes four arguments, as described in the following table.

Table 4–4 invokeMethod Parameters


Data Type 




The name of the instance on which the method must be invoked 



The name of the method to call 



Input parameters to pass to the method 



Output parameters to get from the method 

Example 4–15 Calling a Method

This example gets the instances of the CIM_Service class, which represent services that manage device or software features. The example uses the invokeMethod method to stop each service.

    /* Pass the CIM Object Path of the CIM_Service class 
    to the CIM Object Manager. We want to invoke a method defined in
    this class. */ 
    CIMObjectPath op = new CIMObjectPath("CIM_Service"); 
    /* The CIM Object Manager returns an enumeration of instance
    object paths, the names of instances of the CIM_Service 
    class. */
    Enumeration e = cc.enumerateInstanceNames (op, true); 
    /* Iterate through the enumeration of instance object paths */
    while(e.hasMoreElements()) {
                // Get the instance
                CIMObjectPath op = (CIMObjectPath) e.nextElement();
                //Invoke the Stop Service method to stop the CIM services.
                cc.invokeMethod("StopService", null, null);