VMware {code} Community
AlanSthomas
Contributor
Contributor

Need help with SOAP request for guest operations

I'm working on a php script to do some automation. This is using the standard SOAP/WSDL and PHP. Mostly things are going well, but I have ran into an issue with guest operations. Can anyone either post the XML request/response or give an example using the MOB. I've been working with listFilesInGuest, but anything will do. I just need to understand how the guest authorization works. I've been able to use pyvmomi to get this, but I can't seem to figure out how to output the request/response in python. My requirement is for PHP so I can't move to python either.

 

Any help is greatly appreciated.

Reply
0 Kudos
1 Reply
AlanSthomas
Contributor
Contributor

I finally figured this out. I have to say there are some real disconnects in VMware. Onyx was a great help, but as it doesn't support http, I ended up writting a man in the middle attack to dump the XML.

Anyway for anyone looking for help on how to do this, best I can tell the WDSL is broken. At least with php. I couldn't get it the function call to work, even though I have many others working fine. So I moved to raw XML and CURL. To be clear, I'm using CURL just for this. I'm sticking to the WDSL for everythen else.

Here is what you need to send as a POST.

          <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

          <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

          <InitiateFileTransferToGuest xmlns="urn:vim25">

          <_this type="GuestFileManager">guestOperationsFileManager</_this>

          <vm type="VirtualMachine">vm-521</vm>

          <auth xsi:type="NamePasswordAuthentication">

          <interactiveSession>false</interactiveSession>

          <username>root</username>

          <password>password</password>

          </auth>

          <guestFilePath>/root/test.txt</guestFilePath>

          <fileAttributes/>

          <fileSize>14</fileSize>

          <overwrite>false</overwrite>

          </InitiateFileTransferToGuest>

          </s:Body>

          </s:Envelope>

The response will have a URL for you to POST the file to. Again I used curl. You do need to set the cookie for auth, which you can pull from the last SOAP response. I also needed to set header SOAPAction. Again you can pull from the last response. Outside of that its just standard stuff.

Hope this helps someone.

Reply
0 Kudos