6.5

Table Of Contents
VMware, Inc. 57
Chapter A Web Services for Management Perl Library
#Construct the client.
$client = WSMan::WSBasic->new(
path => 'wsman',
username => 'wsman',
password => 'secret',
port => '8889',
address => 'http://something.somewhere.com'
);
#Execute the Enumerate method.
$result = $client->Enumerate(class_name => 'CIM_Processor',
#namespace => 'root/cimv2'
);
if($result->fault){
#If a fault occurred, then print the faultstring
die $result->faultstring;
}
else{
#If no fault occurred then get the enumid.
$enumid = $result->result;
}
$result = $client->PullRelease(
class_name => 'CIM_Processor',
enumid => $enumid,
action => 'Pull',
#namespace => 'root/cimv2'
);
if($result->fault){
#If a fault occurred, then print the faultstring
die $result->faultstring;
}
else{
# Do stuff with $result, which is a SOAP::SOM object containing a deserialized XML reply.
# It is better to use the Generic Operations module, built on top of this module.
}
Generic CIM Operations with WSMan::GenericOps
TheGenericOpsmoduleimplementssomeofthegenericoperationsspecifiedintheWSManagementCIM
bindingspublishedbytheDMTF.Notallgenericoperationsareimplemented.ThePerlmoduleislocatedat
Perl/lib/WSMan/GenericOps.pm.
TheWSBasicmodulediscussedin“SOAPMessageConstructionwithWSMan::WSBasic”onpage 53provides
moreprimitiveintrinsicWSManagement
operations.TheGenericOpsmodulerequirestheWSMan::WSBasic
module.
Table A4liststhemethodstheGenericOpsclassprovides,whicharediscussedinmoredetailbelow.
Table A-4. Methods in WSMan::GenericOps
Method Description
WSMan::GenericOps>new Constructor .
register_xml_ns RegistersextraXMLnamespacesthatmightberequiredforproprietarytagsinthe
SOAPmessage.
register_class_ns RegistersextraCIMnamespacesthattheWSManagementservermightrequire.
Identify Performsthewsmid:Identifyoperation,whichcausestheWSManagementserver
toidentifyitself.
EnumerateInstances Enumeratestheinstancesofagivenclass.
EnumerateInstanceNames Enumerates
onlythekeyvaluesoftheinstancesofagivenclass.
EnumerateAssociatedInstances Returnstheinstancesrelatedtothesourceobjectthroughanassociation.
EnumerateAssociatedInstanceNames Returnsobjectswithonlythekeyvaluesoftheassociatedinstancepopulated.
EnumerateAssociationInstances Returnsobjectscontainingassociationinstancesofwhichtheclassisapart.