如何配置vSphere 6 SOAP调用以显示资源池或数据中心?

VMware vSphere 6.0 WSDL API

See documentation at: http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.pg.doc/PG_Introduction_Inventory.6.4.html

I am trying to retrieve a list of datacenters in a VMware vCenter Inventory, and there is one datacenter present.

I have created a SOAP call in PHP as follows ($request is print_r()ed):

stdClass Object(
        [_this] => stdClass Object(
            [_] => propertyCollector
            [type] => PropertyCollector
        )
    [specSet] => Array(
            [propSet] => Array(
                    [0] => Array(
                            [type] => ResourcePool
                            [all] => 1
                        )
                )
            [objectSet] => Array(
                    [obj] => stdClass Object(
                            [_] => group-d1
                            [type] => Folder
                        )
                    [skip] => 
                    [selectSet] => Array(
                            [0] => SoapVar Object(
                                    [enc_type] => 301
                                    [enc_value] => Array(
                                            [name] => FolderTraversalSpec
                                            [type] => Folder
                                            [path] => childEntity
                                            [skip] => 
                                            [0] => SoapVar Object(
                                                    [enc_type] => 301
                                                    [enc_value] => Array(
                                                            [name] => FolderTraversalSpec
                                                        )
                                                    [enc_name] => selectSet
                                                )
                                            [1] => SoapVar Object(
                                                    [enc_type] => 301
                                                    [enc_value] => Array(
                                                            [name] => DataCenterVMTraversalSpec
                                                        )
                                                    [enc_name] => selectSet
                                                )
                                        )
                                    [enc_stype] => TraversalSpec
                                )
                            [1] => SoapVar Object(
                                    [enc_type] => 301
                                    [enc_value] => Array(
                                            [name] => DataCenterVMTraversalSpec
                                            [type] => Datacenter
                                            [path] => datastoreFolder
                                            [skip] => 
                                            [0] => SoapVar Object(
                                                    [enc_type] => 301
                                                    [enc_value] => Array(
                                                            [name] => FolderTraversalSpec
                                                        )
                                                    [enc_name] => selectSet
                                                )
                                        )
                                    [enc_stype] => TraversalSpec
                                )
                        )
                )
        )
)

I believe the [path] => datastoreFolder is incorrect, and VMware documentation shows datastoreFolder, hostFolder, networkFolder, and vmFolder. There are no datacenters in any of them, and any other object seems to break the SOAP call with an error.

Is there a way to retrieve the datacenters clusters using a soap call?

I've been having the same problem. Then I took a closer look at this page:

https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.Datacenter.html

Quote:

Every Datacenter has the following set of dedicated folders. These folders are empty until you create entities for the Datacenter.

A folder for VirtualMachine, template, and VirtualApp objects. A folder for a ComputeResource hierarchy. A folder for Network, DistributedVirtualSwitch, and DistributedVirtualPortgroup objects. A folder for Datastore objects.

You are using ResourcePool in your propSet, but that does not exists for a Datacenter.

[propSet] => Array(
        [0] => Array(
                [type] => ResourcePool
                [all] => 1
            )
    )

This is what I use to read all the hosts:

[propSet] => Array
    (
        [0] => Array
            (
                [type] => ComputeResource
                [all] => 1
            )
    )

[objectSet] => Array
    (
        [obj] => stdClass Object
            (
                [_] => group-d1
                [type] => Folder
            )

        [skip] => 
        [selectSet] => Array
            (
                [0] => SoapVar Object
                    (
                        [enc_type] => 301
                        [enc_value] => Array
                            (
                                [name] => FolderTraversalSpec
                                [type] => Folder
                                [path] => childEntity
                                [skip] => 
                                [0] => SoapVar Object
                                    (
                                        [enc_type] => 301
                                        [enc_value] => Array
                                            (
                                                [name] => FolderTraversalSpec
                                            )

                                        [enc_name] => selectSet
                                    )

                                [1] => SoapVar Object
                                    (
                                        [enc_type] => 301
                                        [enc_value] => Array
                                            (
                                                [name] => DataCenterVMTraversalSpec
                                            )

                                        [enc_name] => selectSet
                                    )

                            )

                        [enc_stype] => TraversalSpec
                    )

                [1] => SoapVar Object
                    (
                        [enc_type] => 301
                        [enc_value] => Array
                            (
                                [name] => DataCenterVMTraversalSpec
                                [type] => Datacenter
                                [path] => hostFolder
                                [skip] => 
                                [0] => SoapVar Object
                                    (
                                        [enc_type] => 301
                                        [enc_value] => Array
                                            (
                                                [name] => FolderTraversalSpec
                                            )

                                        [enc_name] => selectSet
                                    )

                            )

                        [enc_stype] => TraversalSpec
                    )

            )

    )

)

I don't know if it helps, I just hope so! Good luck.