Run a workflow from an external program

A LiveCompare workflow that has been registered as a Web Service may be called from an external program, for example from a Python script, or from Revelation Software’s Rev-Trac application. When a workflow is run from an external program:

  1. The workflow is registered as a Web Service, producing a URL that references a Web Service Definition Language (WSDL) script.

  2. The external program uses the URL to run the script, providing values that will be passed to the workflow’s input parameters.

  3. The script instructs LiveCompare to run the workflow, using the values provided for the workflow’s input parameters.

  4. When the workflow completes, the WSDL script returns the workflow’s result to the calling program.

Running Workflows from External Programs.

Workflows run in this manner are executed asynchronously. The external program invokes the workflow using the workflow’s Web Service definition, and control then is immediately returned to the external program while the workflow is running. The external program must poll the workflow periodically in order to monitor its execution status and obtain any results that are returned when the workflow has completed.

The WSDL script provides two operations, named StartWorkflow() and EndWorkflow().

General steps

In general, the following steps are required to call a workflow from an external program.

Check that the external program can access LiveCompare

The external program accesses LiveCompare a WSDL script that references the LiveCompare URL. If the external program and LiveCompare are on different server’s, confirm that the external program’s server can access the LiveCompare logon screen at http://<LiveCompare server name>/livecompare.

Check the workflow’s prerequisites

When a workflow is called from an external program, the workflow is run in LiveCompare. If a workflow has any prerequisites (for example, it may need access to an object links cache database), you should confirm that these have been met before calling the workflow from the external program. In most cases, you can check that a workflow’s prerequisites have been met by running the workflow directly in LiveCompare and confirming that it completes successfully.

Register the workflow as a Web Service

To register a workflow as a Web Service, carry out the following steps:

  1. Confirm there are no spaces or non-alphanumeric characters in the workflow’s name, input parameters or output datasets.

  2. Select the workflow in the LiveCompare hierarchy and choose ‘Register as Web Service’ from the context menu. The following screen is displayed:

Register Workflow as Web Service Wizard.

  1. Select the input parameters for which the external program will provide values, and click ‘Next’ to continue. The following screen is displayed:

Register Workflow as Web Service Wizard.

  1. Select the output dataset whose value will be returned to the external program, and click ‘Next’ to continue. The following screen is displayed:

Register Workflow as Web Service Wizard.

  1. Confirm your selections, click ‘Finish’ to complete the Wizard.

If a workflow calls one or more sub-workflows, only the top-level workflow should be registered as a Web Service.

Create an API token for the Web Service

API tokens provide a level of authentication for the WDSL links obtained from workflows registered as Web Services. A Web Service may not be accessed via its URL unless it has at least one valid API token. API tokens have expiration dates, and are valid for either 30, 60 or 90 days.

To create an API token for the Web Service, carry out the following steps:

  1. Log in to LiveCompare using the ‘admin’ account.

  2. Select the Data/Web Services hierarchy folder, and locate the Web Service for which to create an API token.

  3. Click ‘Make API Token’ to display the Create API Token screen.

Create API Token screen.

  1. Set an expiration period for the API token, and click ‘Create API Token’. The API token is listed in the API Tokens screen.

API Tokens screen.

Copy the WSDL link

To copy the Web Service’s WSDL link, carry out the following steps.

  1. Select the Data > Web Services folder in the LiveCompare hierarchy.

  2. Locate the entry for the workflow that was registered as a Web Service.

  3. Right click the WSDL link and choose ‘Copy link address’ from the context menu.

The copied WSDL link may now be used in the external program.

Example: Call a workflow from a Python script

The RevTracTest workflow in the Tools templates folder has the same input parameters and output datasets as the SmartImpact_RevTrac workflow, which is used to perform an impact analysis. However, it runs very quickly as only produces a mock report. Here is a Python script that calls the workflow using its WSDL link and the API token that was generated for it.

from requests import Session

from zeep import Client

from zeep.transports import Transport

def RevTracTest():

WSDL = 'http://localhost/livecompare/studio/WebServices/RevTracTest.lcsx?WSDL'

session = Session()

session.verify = False

transport = Transport(session=session)

headers = {

# Update this the following line with your API token

'Authorization': 'Bearer E2F5AFE8E1784F33992FC8C7474ADB05'

}

session.headers.update(headers)

client = Client(WSDL, transport=transport)

stringlist_array_type = client.get_type("ns0:StringList")

transport_list = stringlist_array_type(['EH4K900836', 'EH4K900842'])

swr = client.service.StartWorkflow(System1='S1', System2='S2', System3='S3', Transports= transport_list)

token = swr['token']

ewr = client.service.EndWorkflow(token=token)

while True:

status = ewr['status']

if status == 'FAILED':

break

if status == 'COMPLETED':

break

ewr = client.service.EndWorkflow(token=token)

if status == 'COMPLETED':

print('ReportUrl: {0}'.format(ewr['workflowResult']['ReportUrl']))

RevTracTest();

The SmartImpact_RevTrac workflow in the Impact Analysis templates folder may be registered as a Web Service and called from the Python script above by modifying the ‘WSDL =’ line to point to the new WDSL link. In this case, a full impact analysis will be performed, and the resulting Impact Analysis report will be returned to the Python script.

Example: Call a workflow from Rev-Trac

When LiveCompare is integrated with Rev-Trac, LiveCompare performs an impact analysis automatically after a Rev-Trac request status has been approved. When the analysis is complete, a reference is updated in the Rev-Trac request that points to the Impact Analysis report URL returned by LiveCompare.

The WSDL link of the impact analysis workflow to be called is set in Rev-Trac’s Impact Analysis URL field. This may be set to the WDSL link for the RevTracTest workflow to provide a quick test to verify that the integration is working. Afterwards, the Impact Analysis URL field may be updated with the WSDL link of the SmartImpact_RevTrac workflow to allow Rev-Trac to initiate a full impact analysis.

Please refer to the documentation provided by Revelation Software for specific details on how to configure Rev-Trac to perform an Impact Analysis using LiveCompare.

Run a workflow from an external program - Adder example

Workflow operations