<?php
class soapclientd extends soapclient
{
public $action = false;
public function __construct($wsdl, $options = array())
{
parent::__construct($wsdl, $options);
}
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$resp = parent::__doRequest($request, $location, $action, $version, $one_way);
return $resp;
}
}
function reconfigs($hostname,$username,$password) {
$client = new soapclientd('http://'.$hostname.'/sdk/vimService.wsdl', array ('location' => 'http://'.$hostname.'/sdk', 'trace' => 1));
try
{
$request = new stdClass();
$request->_this = array ('_' => 'ServiceInstance', 'type' => 'ServiceInstance');
$response = $client->__soapCall('RetrieveServiceContent', array((array)$request));
} catch (Exception $e)
{
return $e->getMessage();
}
$ret = $response->returnval;
try
{
$request = new stdClass();
$request->_this = $ret->sessionManager;
$request->userName = ''.$username.'';
$request->password = ''.$password.'';
$response = $client->__soapCall('Login', array((array)$request));
} catch (Exception $e)
{
return $e->getMessage();
}
$res = null;
try
{
$request = new stdClass();
$request->_this = array ('_' => 'vm-20', 'type' => 'VirtualMachine');
$request->spec = array (
'deviceChange' => array (
'operation' => 'edit',
'device' => array (
'key' => '3002',
'deviceInfo' => array('label' => 'CD/DVD drive 1', 'summary' => 'ISO [datastore1] Windows Server 2008.iso'),
'connectable' => array('startConnected' => 'false', 'allowGuestControl' => 'false', 'connected' => 'false'),
'backing' => array('filename' => 'ISO [datastore1] Windows Server 2003.iso', 'datastore' => 'datastore-11'),
'controllerKey' => '201',
'unitNumber' => '1',
)
)
);
$res = $client->__soapCall('ReconfigVM_Task', array((array)$request));
} catch (Exception $e)
{
print_r ($e->getMessage());
}
print_r ($res);
}
But i give error Invalid Operation Error '0' Help