Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to determine type of Any error #3

Open
xgylog opened this issue May 29, 2013 · 5 comments
Open

Unable to determine type of Any error #3

xgylog opened this issue May 29, 2013 · 5 comments

Comments

@xgylog
Copy link

xgylog commented May 29, 2013

Hi, great job! everything went fine until I try some codes to modify vm's extraConfig.

$vm = $vhost->findManagedObjectByName('VirtualMachine', 'new', array('config'));
$vmconf = $vm->config;
$vmExConf = $vmconf->extraConfig;
$vmExConf1[] = new OptionValue('RemoteDisplay.vnc.enabled','true');
$vmcs = new VirtualMachineConfigSpec();
$vmcs->extraConfig = $vmExConf1;
$vm->ReconfigVM_Task(array('spec'=>$vmcs));

here is the error message(Webservice faultString):

PHP Fatal error: Uncaught SoapFault exception: [ServerFaultCode]
Unable to determine type of Any

error parsing Any value
at line 2, column 253

while parsing property "value" of static type anyType

while parsing serialized DataObject of type vim.option.OptionValue
at line 2, column 192

while parsing property "extraConfig" of static type ArrayOfOptionValue

while parsing serialized DataObject of type vim.vm.ConfigSpec
at line 2, column 182

while parsing call information for method ReconfigVM_Task
at line 2, column 115

while parsing SOAP body
at line 2, column 100

while parsing SOAP envelope
at line 2, column 0

while parsing HTTP request for method reconfigure
on object of type vim.VirtualMachine
at line 1, column 0 in C:\wamp\www\VMPHP\vmwarephp\library\Vmwarephp\Service.php:68
Stack trace:
#0 C:\wamp\www\VMPHP\vmwarephp\library\Vmwarephp\Service.php(68): SoapClient->__call('ReconfigVM_Task', Array)
#1 C:\wamp\www\VMPHP\vmwarephp\library\Vmwarephp\Service.php(68): Vmwarephp\SoapClient->ReconfigVM_Task(Array)
#2 C:\wamp in C:\wamp\www\VMPHP\vmwarephp\library\Vmwarephp\Service.php on line 68

I track down the soap request, do it in SoapUI, same error message shows.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:vim25">
SOAP-ENV:Body
ns1:ReconfigVM_Task
<ns1:_this type="VirtualMachine">2/ns1:_this
ns1:spec
ns1:extraConfig
ns1:keyRemoteDisplay.vnc.enabled/ns1:key
ns1:valuetrue/ns1:value
/ns1:extraConfig
/ns1:spec
/ns1:ReconfigVM_Task
/SOAP-ENV:Body
/SOAP-ENV:Envelope

I'm pretty sure ns1:valuetrue/ns1:value is the cause the problem, I look into the source code OptionValue class which indicate 'value' property is a type of //AnyType. Is there anyway I can quick fix this, thanks.

@vadimcomanescu
Copy link
Owner

Hey sorry for the very very late reply. I will take a look into this.

@vadimcomanescu
Copy link
Owner

Still looking couldn't find a solution yet. I will get back.

@quietust
Copy link

I encountered this same problem when writing my own code for talking to vSphere (back in late 2012, before this project even existed), and I managed to find a solution: iterate across $vmExConf and reassign all of the values with "new SoapVar($value, XSD_STRING, 'xsd:string')".

@strstr1
Copy link

strstr1 commented May 20, 2022

@quietust Could you please provide a working example?

I try since 2 days to get this working :( Currently, i try something like that:

            $get = $this->vmware->findOneManagedObject('VirtualMachine', $this->vmid, array());
            $newSpec = new VirtualMachineConfigSpec();
            $newSpec->extraConfig = $get->config->extraConfig;

            foreach ($newSpec->extraConfig as $k => $v) {
                $newSpec->extraConfig[$k] = new SoapVar($v, XSD_STRING, 'xsd:string');
                //$newSpec->extraConfig[$k]['value'] = new SoapVar($v, XSD_STRING, 'xsd:string');
                //$newSpec->extraConfig[$k] = new OptionValue ($k, new SoapVar($v, XSD_STRING, 'xsd:string')); 
            }

I would be grateful for any help.

@strstr1
Copy link

strstr1 commented May 20, 2022

I got it working :)

  foreach ($newSpec->extraConfig as $k => $v) {
        $newSpec->extraConfig[$k] = new OptionValue ($v->key, new SoapVar($v->value, XSD_STRING, 'xsd:string'));
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants