When calling an Orchestrator workflow from outside via the SOAP-API, things get dirty if your workflow have input parameters (see details here: http://www.vcoportal.de/2011/06/updated-calling-vco-workflows-from-powershell/ ). And things get really dirty, if the input parameter is an Inventory Object (like a Virtual Machine, provided by the vCenter Plugin).
The reason for that:
Before you can finally call the actual workflow, you have to get the vCO-internal ID of the object, usually by calling other API-methods before. In the vCO WebService documentation you can find following flow-chart, I marked the step we’re talking about:
Depending on what information the workflow caller has, you can call the findForId, or the find method with an xpath-expression. (expecially when working with the vCenter-plugin, always remember: The managed object Id in vCenter or the name of the Virtual Machine is not necessarily unique in vCO, because you always can have connections to multiple vCenter-Hosts!)
Thanks to David (@creativeview) and Igor a full example in Powershell:
$vcoWS = New-WebServiceProxy -Class VCO -Namespace VCO -Uri http://mycoolvcoappliance:8280/vmware-vmo-webcontrol/webservice?WSDL #find the workflow $workflows = $vcoWS.getWorkflowsWithName("Start virtual machine and wait", "vcoadmin" , "vcoadmin") #find the virtual machine $result = $vcoWS.find("VC:VirtualMachine", "xpath:name='TheVM-Name'", "vcoadmin" , "vcoadmin") if ($result.TotalCount -gt 0) { #$result $finderResult = $result.Elements[0] $stringObjectRepresentation = $finderResult.DunesUri #Write-Host $stringObjectRepresentation } $workflow = $workflows[0] # print out input Parameters $workflow.inParameters # generate Array with Input PArameters (WorkflowTokenAttribute - Objects) $inparams = @() # fill the array, one entry for each input parameter $inparams += New-Object -TypeName VCO.WorkflowTokenAttribute $inparams[0].name = "VM" $inparams[0].type = "VC:VirtualMachine" $inparams[0].value = $stringObjectRepresentation # Exectue workflow $workflowToken = $vcoWS.executeWorkflow($workflow.id, "vcoadmin" , "vcoadmin", $inparams)
See the full discussion in the forums (some Java lines included as well 🙂 ):
http://communities.vmware.com/message/1889504#1889504
My original example how to call vCO Workflows via Powershell (with plain data types for input only :oops:):
http://www.vcoportal.de/2011/03/powershell-vco/
You can also find some examples about this in the vco-examples-package, more information how to get started with this:
http://www.vcoportal.de/2011/08/sample-webservice-client-for-vco/
And an unofficial tip at the end: Rumors are that the next major release of vCO contains a new REST-based API, so don’t spend too much time learing this legacy stuff, if you don’t need to…