Hi I've found this question in lots of places, but it never seems to be answered. I'm optimistic...
I am using custom tasks, and am able to set the progress, and the state to "TaskInfoState.SUCCESS" without any problems.
But if something goes wrong during my task, I want to set the task state to "error" - and add a message why.
so I use vimPort.setTaskState(taskInfo.getTask(), TaskInfoState.ERROR, null, taskMethodFault);
My taskMethodFault is a LocalizedMethodFault -
It expects a MethodFault, and a localized Message -
The MethodFault expects a FaultCause which is a LocalizedMethodFault - which then expects a never ending number of Faults...
Here's what the soap exception says:
com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: required tag not seen while processing MethodFault at line 1, column 374 while parsing property "faultCause" of static type MethodFault while parsing serialized DataObject of type vmodl.MethodFault at line 1, column 367 while processing MethodFault at line 1, column 355 while parsing property "faultCause" of static type MethodFault while parsing serialized DataObject of type vmodl.MethodFault at line 1, column 348 while processing MethodFault at line 1, column 341 while parsing call information for method SetTaskState at line 1, column 110 while parsing SOAP body at line 1, column 102 while parsing SOAP envelope at line 1, column 38 while parsing HTTP request for method setState on object of type vim.Task at line 1, column 0 Please see the server log to find more detail regarding exact cause of the failure.
So can someone please publish some sample code which lets you set a task state to TaskInfoState.ERROR that works? I can't image that it could be so difficult.
I found the solution - at least it worked for me
it looks something like this
1) When the extension is registerd, create a Fault resource for "myFaultType";
When the task should fail - use the ExtendedFault -->
ExtendedFault extendedFault = new ExtendedFault();
LocalizedMethodFault localizedMethodFault = new LocalizedMethodFault();
vimPort.setTaskState(taskInfo.getTask(), TaskInfoState.ERROR, null, localizedMethodFault);
so that seems to work
Could someone verify this - or should it be done another way?