工作流的展示可以定义传递到工作流输入参数的值的限制,例如预定义值列表或特定值范围。若要确保工作流成功运行,您必须根据工作流展示的定义对传递到工作流输入参数的值进行验证。
在自定义应用程序中集成工作流时,您可能需要创建一个向导,在其中输入工作流运行时的输入参数值。通过使用工作流展示服务,您可以实例化工作流的展示并对应向导的不同屏幕分批传递输入参数值。您可以根据工作流展示中定义的限制对传递到输入参数的值进行验证。
前提条件
确认您已导入 Orchestrator 中的示例工作流软件包。该软件包随附在 Orchestrator 示例应用程序 ZIP 文件中,您可从 Orchestrator 文档页面中下载该文件。
过程
验证其输入参数来运行发送问候工作流
您可以根据“发送问候”工作流的展示定义验证其输入参数,从而运行此工作流。
在持有“发送问候”工作流定义的 URL 发起 GET 请求:
GET https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/
您会在请求的响应正文中收到工作流定义:
<xml version="1.0" encoding="UTF-8" standalone="yes"> <workflow xmlns="http://www.vmware.com/vco" customized-icon="false" href="https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/"> <relations> <link rel="up" href="https://localhost:8281/vco/api/inventory/System/Workflows/Samples/HelloWorld/" /> <link rel="add" href="https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/executions/" /> <link rel="down" href="https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/executions/" /> <link rel="down" href="https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/presentation/" /> <link rel="down" href="https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/tasks/" /> <link rel="down" href="https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/icon/" /> </relations> <input-parameters> <parameter name="name" type="string" /> </input-parameters> <output-parameters> <parameter name="message" type="string" /> </output-parameters> <name>Send Hello</name> <description></description> </workflow>
在持有工作流展示定义的 URL 发起 GET 请求:
GET https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/presentation/
在持有工作流展示执行实例的 URL 发起 POST 请求:
POST https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/presentation/instances/
提供空的 execution-context 以便仅实例化展示而不提供任何输入参数值:
<execution-context xmlns="http://www.vmware.com/vco"/>
响应正文包含附加到每个字段的错误消息,表示输入参数的值无效。
....... <fields> <field type="string" hidden="false" id="name"> <display-name>name</display-name> <description>name</description> <messages> <message severity="ERROR" code="VCO-CNS0002"> <Summary> The minimum number of characters allowed for this field is 3.0 </Summary> </message> </messages> <constraints> <number-range max="15.0" min="3.0" /> </constraints> .......
在持有特定展示实例的 URL 发起 POST 请求:
POST https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/presentation/instances/888080808080808080808080808080803F8080800132145338690643f66a027ec/
在请求正文中,提供输入参数的值:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <execution-context xmlns="http://www.vmware.com/vco"> <parameters> <parameter name="name" type="string"> <string>John Smith</string> </parameter> </parameters> </execution-context>
在请求的响应正文中,您可以检查输入参数的值是否有效:
<execution started-by="vcoadmin" .... valid="true".....>
如果展示有效,则在持有工作流执行的 URL 发起 POST 请求来运行工作流:
POST https://localhost:8281/vco/api/workflows/CF808080808080808080808080808080DA808080013086668236014a0614d16e1/executions/
在请求正文中,将值传递到工作流的输入参数。使用返回为工作流展示输出参数的相同值,或直接使用对工作流展示发起的最后一个 POST 请求的请求正文。