I've just watched the client doing a copy between datastores using the Copy_Task - which works succesfully. When I try it via the SOAP interface myself though it doesn't work. Here's the request I'm sending:
REQUEST: $VAR1 = 'POST https://docsserver1.testing.local/sdk
Content-Type: text/xml; charset="utf-8"
SOAPAction: "urn:vim25/4.0"
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope 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>
<Copy_Task xmlns="urn:internalvim25"><_this type="FileManager">ha-nfc-file-manag
er</_this>
<sourcePath>[vmstore] VM2</sourcePath><sourceDatacenter type="Datacenter">ha-dat
acenter</sourceDatacenter>
<destinationPath>[datastore1] VM2</destinationPath><fileType>File</fileType><for
ce>false</force></Copy_Task></soapenv:Body></soapenv:Envelope>
';
RESPONSE: $VAR1 = '<?xml version="1.0" encoding="UTF-8"?>
<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>destinationPat
h</faultstring><detail><InvalidRequestFault xmlns="urn:internalvim25" xsi:type="
InvalidRequest"></InvalidRequestFault></detail></soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>';
destinationPath
Here's what the client is doing:
POST /sdk HTTP/1.1
User-Agent: VMware VI Client/4.0.0
Content-Type: text/xml; charset="utf-8"
SOAPAction: "urn:internalvim25/4.0"
Host: docsserver1.testing.local
Cookie: vmware_soap_session="5205f714-4967-1661-4728-50f54a9750d5"
Content-Length: 636
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Copy_Task xmlns="urn:internalvim25">
<_this xsi:type="FileManager" type="FileManager" serverGuid="">ha-nfc-file-manager</_this>
<sourceDatacenter type="Datacenter" serverGuid="">ha-datacenter</sourceDatacenter>
<sourcePath>[vmstore] VM2</sourcePath>
<destinationPath>[datastore1] VM2</destinationPath>
<force>false</force>
<fileType>File</fileType>
</Copy_Task>
</soap:Body>
</soap:Envelope>
It gets back a valid response:
HTTP/1.1 200 OK
Date: Tue, 14 Jul 2009 14:56:21 GMT
Cache-Control: no-cache
Content-Type: text/xml; charset=utf-8
Content-Length: 466
<?xml version="1.0" encoding="UTF-8"?>
<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>
<Copy_TaskResponse xmlns="urn:internalvim25"><returnval type="Task">haTask--vim.FileManager.copy-1852798755</returnval></Copy_TaskResponse>
</soapenv:Body>
</soapenv:Envelope>
I'm sending what appears to be the exact same thing as the client, but it doesn't seem to work. Any ideas?
Hi,
Copy_Task is an internal API that is used by VI Client to copy the files between datastores. This API is not exposed in the WSDL. VI APIs provide CopyDatastoreFile_Task method that can be used to copy the file from one datastore to another.
You can also refer to the following thread for sample code:
http://communities.vmware.com/message/1130213
Hope this information is helpful.