vmware

VMware Webservices

VMware deploys with a broken webservice (the definitions are incomplete)
This can be easily fixed by following these steps.

Download the SDK from VMware and manually install the definitions
I hope this posts saves you some headache.

  1. Download the VMware SDK
  2. Extract all files
  3. Copy the files from SDK/vsphere-ws/wsdl/vim and SDK/vsphere-ws/wsdl/vim25 to your server e.g. C:\ProgramData\VMware\VMware VirtualCenter\docRoot\sdk
    (may be located elsewhere on your server)

Thats it. You may restart your “VMware vCenter Server Web Services HTTP” (via services) and everything should work perfectly.

Another headache case is connecting via the standard PHP-SoapClient since VMware accepts ONLY correctly namespaced XML packets

To solve this you’ll have to override your SoapClient here below I’ll demonstrate how to override

//Overridden SoapClient (basically it injects the default XML-Schema instance)
class VMware_SoapClient extends SoapClient
{
    public function __doRequest($request,$location,$action,$version,$one_way = 0)
    {
        $inject = 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
        if (strpos($request, $inject) === false) {
            $pos = strpos($request, 'xmlns:');
            if ($pos !== false) {
                $pos = strpos($request, '>', $pos);
                if ($pos !== false) {
                    $request = substr($request, 0, $pos) . ' ' . $inject . substr($request, $pos);
                }
            }
        }
        return parent::__doRequest($request, $location, $action, $version, $one_way);
    }
}

Comments

Leave a Reply