VMware {code} Community
dima_misiura
Contributor
Contributor

Getting complete list of servers and attributes directly from web services

We want to utilise web services provided by vSphere directly bypassing Java or C# libraries as part of our "environment discovery" routine which would be periodically performed by a Middleware platform. We want to configure it to poll vSphere web services and extract necessary data and store it in a database repository accessed by other applications. We definitely don't want to build any custom code to invoke web services via libraries provided by vmware.

I am able to successfully get the list of methods exposed (https://ourvmwareserver/sdk/vimService.wsdl) and use Login method to get the key and then use the key to invoke some other methods in SoapUI.

Now after spending few hours going through the SDK manuals I am at complete loss as to how exactly I can get the list of servers and their attributes using this approach. Can someone help with that please?

Reply
0 Kudos
2 Replies
dima_misiura
Contributor
Contributor

Ok,

After playing for a while I managed to move as far as this:

I authenticate successfully and pass on cookie with every request.

Then I try to use RetrievePropertiesEx method

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">

   <soapenv:Header/>

   <soapenv:Body>

      <urn:RetrievePropertiesEx>

         <urn:_this type="PropertyCollector">PropertyCollector</urn:_this>

         <!--1 or more repetitions:-->

         <urn:specSet>

          

            <!--1 or more repetitions:-->

            <urn:propSet>

              

               <urn:type></urn:type>

               <!--Optional:-->

               <urn:all>true</urn:all>

            </urn:propSet>

            <!--1 or more repetitions:-->

            <urn:objectSet>

                

               <urn:obj type="Datacenter"></urn:obj>

               <!--Optional:-->

               <urn:skip>false</urn:skip>

              

            </urn:objectSet>

            <!--Optional:-->

            <urn:reportMissingObjectsInResults>false</urn:reportMissingObjectsInResults>

         </urn:specSet>

         <urn:options>

              

            <!--Optional:-->

            <urn:maxObjects>5000</urn:maxObjects>

         </urn:options>

      </urn:RetrievePropertiesEx>

   </soapenv:Body>

</soapenv:Envelope>

However, what I get is

<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Body>

      <soapenv:Fault>

         <faultcode>ServerFaultCode</faultcode>

         <faultstring>The object has already been deleted or has not been completely created</faultstring>

         <detail>

            <ManagedObjectNotFoundFault xsi:type="ManagedObjectNotFound" xmlns="urn:vim25">

               <obj type="PropertyCollector">PropertyCollector</obj>

            </ManagedObjectNotFoundFault>

         </detail>

      </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

Apparently, something is missing.

Any thoughts?

Reply
0 Kudos
joshames
Enthusiast
Enthusiast

I am very confused why "We definitely don't want to build any custom code to invoke web services via libraries provided by vmware."  Getting all vm's and properties is extremely simple when using vmware.vim libraries.  vimclient.findentityviews method will get you anything you want.

 

josh

Reply
0 Kudos