VMware {code} Community
tdeepak
Contributor
Contributor

When sending the soap request , SetTaskState with the parameter of <state>error</state>, vSphere 5.1 returns a fault string of <InvalidArgumentFault xmlns="urn:vim25" xsi:type="InvalidArgument">.

Below is the corresponding SOAP request/response that is failing.

POST /sdk HTTP/1.1
SOAPAction: urn:vim25/4.0
Content-Type: text/xml; charset=utf-8
Cookie: vmware_soap_session="52ef27c6-e93f-ccc8-a27d-f4fd2c12fc02"; Path=/; HttpOnly;
User-Agent: Java/1.6.0_27
Host: deepak1-lxp:1545
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 422
 
<?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><SetTaskState xmlns="urn:vim25">
<_this>task-2228</_this>
<state>error</state></SetTaskState></soapenv:Body></soapenv:Envelope>
********http://www.doublecloud.org********
HTTP/1.1 500 Internal Server Error
Date: Mon, 21 May 2012 20:10:09 GMT
Cache-Control: no-cache
Connection: Keep-Alive
Content-Type: text/xml; charset=utf-8
Content-Length: 615
 
<?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>A specified parameter was not correct 

             fault</faultstring><detail><InvalidArgumentFault xmlns="urn:vim25" xsi:type="InvalidArgument">

<invalidProperty>fault</invalidProperty> </InvalidArgumentFault></detail></soapenv:Fault>

               Any idea why this could be happening?

0 Kudos
2 Replies
Steve_Jin
Expert
Expert

As the returned message says, the argument caused the trouble was the fault argument, which is of type MethodFault. According to the API reference, the fault argument is really optional. But my guess is that when you give a state of error, the fault argument becomes required. So this is really conditionally optional. So to fix the problem, you may want to pass in fault argument.

Steve, author of vSphere and VI SDK, creator of open source vijava API managing vSphere, http://www.doublecloud.org

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos
soumyatri
Contributor
Contributor

Hi Steve,

Even we hit the same problem for vSphere 5.1 (using VI-Java 5.0.1).

As u suggested, we tried to pass a "fault" paramerer as follows.

(VI Java setTaskState() API takes LocalizedMethodFault object as parameter.)

LocalizedMethodFault fault = new LocalizedMethodFault();

fault.setLocalizedMessage("My Error");

MethodFault methodFault = new MethodFault();

fault.setFault(methodFault);

task.setTaskState(TaskInfoState.error, null, fault);

Still, the above line is throwing exception.

And though the task is getting marked as failed/error, but the status field shows "MessageFault.summary".

Our requirement is simple - just mark the task as Failed/Error.

Is there any way to achieve that?

"tdeepak",

Did you manage to solve this issue?

0 Kudos