We recently switched our code from using VIX to using the new web SDK guest services. We have noticed a strange issue with the InitiateFileTransferFromGuest call. It appears that the first time we call InitiateFileTransferFromGuest for a vm the size property of the returned FileTransferInformation object is 0. If we immediately recall InitiateFileTransferFromGuest we get the correct size and data returned on the HTTP GET call. Subsequent calls to the same vm seem ok after this. But this is repeatable on our other vm's.
We verified that the script if copied to the server and the script is ran as we are outputting the results into a file and this is the file being returned. So there is an issue here. these are both windows 2008 and 2003 vms.
Anyone else seen this behavior. We are also using the dotnet c# sdk.
This could be a problem, but to download the file from Guest you don't need the size information unless you want to monitor progress. I just released Java Guest API using the vSphere 5.0.
It is a problem for sure. Not only is the size zero, but the files being pulled in empty (zero byte) file. We can see the file we are grabing the results from on the server and it has data.
It's interesting. I tried downloading files and it worked just fine with Windows 7. What OS are you using?
These are all windows servers. The code that is calling the web SDK is windows 2008, the servers we are running the guest operations on are both windows 2008/R2 and Windows 2003.
We use the sdk to create a several temp files. Then upload the script, the script sends its output to one of the newly created temp files. Then we grab (transfer from guest) the file and get those results.
Seems like the first time things are accessed its blank and if i got back inthe debugger while its running and tell the code to grab the download url again and then download the file we get it. I dont recall if i mentioned this before, but just to prove that out code for downloading in dotnet wasnt scewed in some way. We used a Internet Explorer tools called Fiddler2 to actually make the get call itself. So we let the code run up to the point where it gets theurl for the download from the sdk. Then used that url in a HTTP GET against the url in question. It also will return an empty file, but if you check the file on the server before and after the call it does have data in it.
Thanks for clarification. What I used is Windows 7 OS for downloading. The Java sample I wrote just worked fine:
Want to try Java? 🙂
BTW, once you got a URL returned from API call, can you open it with a browser? By default, the browser use GET method, so you should be able to download file or view file (if MIME is accepted by your browser). If you cannot get the file, then it's more of an issue of implementation than of APIs itself.
Thanks for hanging in there. There is definitely something wrong here.
This is the first response we got back from the esxi server below:
HTTP/1.1 200 OK
Date: Mon, 12 Mar 2012 23:34:10 GMT
Since the first call was blank we run the call to grab the file again and download it. Now we get the script output as desired.
HTTP/1.1 200 OK
Date: Mon, 12 Mar 2012 23:36:15 GMT
When running in the debugger, we can see that the script runs and outputs the text above to the temp file on the windows server. Something is causing the first download (sometimes) to come back blank. We can even recreate this by using the url in our browser sometimes it comes back without data (blank) the other times it has the data.
I can also confirm that I can see the all of these calls being made in the vCenter events for this esxi server.
I was not aware that we could submit SR's for sdk related issues. Is there a specific place to submit SR's for sdk items or can we use the normal support (SR) channel that we would for vCenter/esxi support?
Yes, you can submit an SR regarding SDK issues and you can use the normal channel and GSS should be able to route it to right team. In addition, there is also specific SDK Support that you can purchase similar to vCenter/ESXi support. You can visit here http://www.vmware.com/support/services/sdk.html for more details
I know this post is a little old but I had never figured out this issue until recently believe it or not. Our file transfers to/from the vm are for executing scripts and reviewing output. We must have been lucky as we only download to view the status and in some rare time get actually data from the vm via a file. Our issue in the past was that we would try to download a file with the url supplied by the initiateFileTransferFromGuest call. We would not get anything back from the VMware host server for download. We could confirm that by making a GET request using the url in fiddler. It always seemed like the first call when debugging would fail, then the next call works perfectly. Well come to fine out the first call was failing with a 500 error when trying to get the file from the VMware host. I spent some more time on this and found the docs related to the InitialteFileTransferFromGuest call and noticed that the docs had been updated to mention to properly authenticate you needed the x509 certificate from the host. We had never seen that nor knew it was required. Once we grabbed the host cert and set the clientCertificate on the HttpWebRequest (this is dotnet) the call worked 100% of the time on the first call. Hopefully this helps others out there as I find the SDK docs for the web client lacking and confusing at times. It would have been nice if the SDK had examples of the upload/download code. but it never has.