Opalis Web Service Example Workflows
Caution |
Test the script(s), processes and/or data file(s) thoroughly in a test environment, and customize them to meet the requirements of your organization before attempting to use it in a production capacity. (See the legal notice here) |
Note: The workflow sample mentioned in this article can be downloaded from the Opalis project on CodePlex: https://opalis.codeplex.com |
Overview
This example demonstrates the Opalis Web Service interface (WS Server) as well as how Opalis can invoke a Web Service (WS Client). The goal of this example is to start and submit parameters to an Opalis Workflow from Opalis by leveraging the Opalis Web Service interface by using the Invoke Web Services and Query XML Activities.
Getting Started
This example require that the Opalis Operator Console is installed.
1. Start Workflow
This Workflow uses the Custom Start Activity to obtain input data using four parameters:
- Username: username for authenticating to the Opalis Web Service
- Password: password for authenticating to the Opalis Web Service
- Summary: a string that represents a message summary
- Details: a string that represents message details
The Invoke Web Services Activity ‘Authenticate’ subscribes to the ‘Username’ and ‘Password’ variables from the Custom Start Activity to submit an XML Request Payload to the Opalis Web Service using the ‘authenticate’ method:
When submitting valid credentials the Activity returns XML data as Published Data ‘XML Response Payload’:
<Envelope>
<Header>
<conversationId>62</conversationId>
</Header>
<Body>
<authenticateResponse>
<token>83623d8839a489bc50229ade528c9e5ba525d1df4b324b372c8819b518dd61d8</token>
</authenticateResponse>
</Body>
</Envelope>
The Query XML Activity ‘Get Token’ subscribes to this data and uses an Xpath query ‘//token’ to obtain the value for token. This token is used to authenticate for further Web Service calls:
The Invoke Web Services Activity ‘Get All Workflows’ subscribes to the result from the ‘Get Token’ Activity to invoke the ‘getAllPolicies’ method:
The Activity returns information about all Workflows as Published Data ‘XML Response Payload’ (extraneous data omitted):
<Envelope>
<Header>
<conversationId>72</conversationId>
</Header>
<Body>
<getAllPoliciesResponse>
<return>
...
<deleted>false</deleted>
<id>{AB89A496-F9D6-4846-916F-9E32E2D0F155}</id>
<name>2. Send Event</name>
<created>
<date>2010-04-8T11:55:22.567-4:00</date>
</created>
<customStart>true</customStart>
<enabled>false</enabled>
<logCommonData>true</logCommonData>
<logSpecificData>true</logSpecificData>
<modified>
<date>2010-05-04T10:34:11-04:00</date>
<user>S-1-5-21-2453516759-3206882576-3424673577-00</user>
</modified>
<offset>
<x>0</x>
<y>0</y>
</offset>
<published>false</published>
<publishedTime>2010-05-04T10:24:21.800-04:00</publishedTime>
<queuedRequests>0</queuedRequests>
<runningInstances>0</runningInstances>
...
</return>
</getAllPoliciesResponse>
</Body>
</Envelope>
The Query XML Activity ‘Get Workflow ID’ subscribes to this data and uses an Xpath query ‘//return[name='2. Send Event']//id’ to obtain the ID for the Workflow named '2. Send Event' :
The Invoke Web Services Activity ‘Get Workflow Parameters’ subscribes to the result from the ‘Get Workflow ID’ Activity to invoke the ‘getCustomStartParametersForPolicy’ method:
The Activity returns information about the parameters that the Workflow named '2. Send Event' accepts:
<Envelope>
<Header>
<conversationId>76</conversationId>
</Header>
<Body>
<getCustomStartParametersForPolicyResponse>
<return>
<id>{ADC7B77A-7065-4160-BCAC-7FCC8C18BFF7}</id>
<name>Details</name>
<policyObjectId>5BDDB282-45B2-461B-978C-4D995CABACAE</policyObjectId>
<type>String</type>
</return>
<return>
<id>{20DEED2F-0270-4680-96F0-A13E68DB26EF}</id>
<name>Summary</name>
<policyObjectId>5BDDB282-45B2-461B-978C-4D995CABACAE</policyObjectId>
<type>String</type>
</return>
</getCustomStartParametersForPolicyResponse>
</Body>
</Envelope>
The Query XML Activity ‘Get Parameter IDs (Flatten)’ subscribes to this data and uses an Xpath query ‘//return[name='Summary']//id|//return[name='Details']//id’ to obtain the IDs for the Parameters accepted by the Workflow named '2. Send Event' :
Instead of returning multi-value Published Data, the Activity is configured to flatten its data and return it as a ‘;’ delimited string:
The Invoke Web Services Activity ‘Start Workflow: 2. Send Event’ subscribes to the result from the ‘Get Parameter IDs (Flatten)’ Activity and the parameters submitted to the Custom Start Activity to invoke the ‘startCustomPolicy’ method. This will start the Workflow named ‘2. Send Event’ and submit the two parameters using the values provided:
It uses the Data Manipulation Function ‘Field’ to refer to the correct element of the Published Data returned by the ‘Get Parameter IDs (Flatten)’ Activity, i.e.
- [Field('{Query result from 'Get Parameter IDs (Flatten)}',';',1)] for the first parameter
- [Field('{Query result from 'Get Parameter IDs (Flatten)}',';',2)] for the second parameter
2. Send Event
This Workflow will be triggered through the Opalis Web Service interface by the Workflow named ‘1. Start Workflow’ . The Custom Start Activity is used to obtain input data using two parameters:
- Summary: a string that represents a message summary
- Details: a string that represents message details
The Send Platform Event Activity is used to display the parameter values:
Running the example Workflow
Launch the Workflow ‘1. Start Workflow’ by starting it from the Operator Console or by running it using the Testing Console. When prompted, enter the appropriate credentials and values:
Check the Operator Console Event screen or the Workflow Testing Console log to see the resulting output from the ‘2. Send Event’ Workflow’ .
More Information
Refer to the Online Help for the Invoke Web Services and Query XML Activities. Search the Online Help for ‘The Web Service’ for more information on the Opalis Web Service Interface.
Share this post : |