Use SOA Execute Activity in Workflows
- Last UpdatedNov 24, 2023
- 7 minute read
SOA Execute is Object Access activity supported by AVEVA Work Tasks. The SOA functionality of AVEVA Work Tasks eliminates the need for custom coding to a great extent by allowing stored data within processes to be easily accessed and reused. This activity is used to access a particular method from a registered Assembly. This section contains information about:
-
Registering the Assembly in a folder
-
Adding the Assembly folder into the SOA Folder
-
Adding the Assembly to the SOA Assembly
-
Create SOA Object Instance in the workflow
-
And finally, displaying the value in an Information activity
Prerequisites
-
Download and install the latest AVEVA Work Tasks.
-
Create a repository.
-
Successfully log on to the repository using administrator credentials.
-
Basic knowledge of how to create a custom assembly.
-
Basic knowledge of how to create a workflow.
Understanding SOA Execute Activity
Step 1: Creating a Custom Assembly
-
Open Microsoft Visual Studio.
-
In the File menu, click New, and the select Project from the menu.
The New Project dialog box appears.
-
In the right pane, select Class Library.
-
Create a .net Class Library.
Example: In the Name text box, enter 'SOATest'.
-
Set the path to save the project.
Example: In the Location drop-down, set the location as C:\SOA using the Browse button.
-
In the Solution Name text box, give the directory name.
By default, it displays the directory name as a specified project name.
-
Click OK.
Sample code for creating the class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SOATest
{
public class Test
{
public Test()
{
}
public string GetName()
{
return "Welcome to SOA";
}
}
}
When you build the project, the dll gets created in the C:\SOA\SOATest\SOATest\bin\Debug folder.
Step 2: Adding the Assembly Folder to the SOA Folder
-
Log on to the Enterprise Console using administrator credentials.
-
On the Enterprise Console, click Menu icon, point to Settings, and then click SOA Folder.
The Folder List page appears.
-
Click New to add a new folder.
-
In the Folder Configuration window, enter the Title as "SOAFolder" and Description as "My first SOA".
-
Specify the Physical Path, that is the path where the folder exists.
-
Give the path and click on the View Assemblies button.
We can now see our dll file listed in the List of Assemblies.
-
Click Save to save all the information.
-
After you save, you can see the dll listed in the SOA Folder window.
Step 3: Adding the Assembly to SOA Assembly Repository
-
In the Enterprise Console, click
menu icon, click Tools, and then click SOA Assembly.
You can use any of the following options to add the assembly:
-
From GAC
-
From Assembly Folder
-
From Web
-
-
Consider adding From Assembly Folder.
-
Click New, and then click From Assembly Folder.
The Select an Assembly window appears.
-
Select the dll file which we had created, that is SOATest.dll, and then click Next.
-
After you select the assembly, you can browse through the namespaces, classes, and methods of the assembly. There is an option to give alias name for the selected methods in the next window, that is Object Setup.
-
Select the methods for which you want to give the alias name, else click Finish & Publish.
-
The Assembly will get added to the Assembly list. Now create a workflow and implement this SOA Assembly in it.
Step 4: Creating a Workflow
-
If you are familiar with the steps of creating a workflow, you can directly navigate to Step 5.
-
In the Enterprise Console, click
menu icon, and then click Workflows.
The Workflows page appears.
-
On the action bar, click New, and then click Workflow.
The New Workflow wizard appears.
-
In the Title box, type a name for the workflow, and in the Description box, type a description for the workflow.
-
Click Save & Continue.
The workflow is created, and the Workflow Options wizard appears.
-
Select Design the Workflow now, which is the default option, and then click Finish.
The Process Designer appears.
Step 5: Creating Object Instance
You have to instantiate an SOA Object Instance to use it in the SOA Execute activity.
-
Right-click the Start activity, and then select Activity Properties.
-
Click on the edit icon near the SOA Object Instances property to instantiate a class for the specific purpose.
-
The SOA Object Instance window appears. Select the appropriate constructor for the specified class.
-
Expand the tree view for the SOA from the SOA Objects in the left pane.
-
Expand till Test, and then click on Actor. It will display the details in the right pane.
-
Click Set.
It opens a new window which displays the constructor.
-
Click OK to save the Constructor.
The constructor will be saved as shown below:
-
Then click Save to save the SOA Instance.
We now have to display the return value from the method as we specified in the Assembly.
-
To create a variable, click on the edit icon near the Variables property in the properties of the Start activity.
-
Create a new variable of Type "String" and click Update to save the variable.
-
Click the Save button in the Activity Properties pane to save all the data entered.
Step 6: SOA-Execute Activity
To use an SOA, add an SOA-Execute activity to the Process Designer.
-
Select Integration Activities from the Activities pane on the left.
-
Drag and drop an SOA-Execute activity to the Process Designer as shown below.
-
Right-click the SOA-Execute activity to get the Activity Properties pane as shown below.
Execute an SOA Expression
-
The SOA-Execute activity uses the SOA through the Expression Editor.
-
Click on the icon near the Execute an SOA Expression to execute the expression.
-
Now we can see the Expression Editor where we will build the expression.
-
Expression Editor comes up with a new node which shows all the available methods or properties.
-
We will build a small expression to get the return value from the method.
-
Drag and drop the GetName() method from the Test node to the right hand side pane and build the expression: string result = Test.GetName();
-
Now we have to save the result to some variable. We save it to the variable that we created in the Start Activity, that is the SOAVariable.
-
Drag and drop the SOAVariable from the Variables node in the left pane to the expression on the right hand side and build the expression:
string result = Test.GetName();
Variable.SOAVariable = result;Click OK to save the expression.
-
Click OK to save the expression.
-
Click the Save button in the Activity Properties pane to save all the data.
-
We have successfully added the SOA-Execute Activity.
Step 7: Display the Return Value of the SOA Method in the Information Activity
-
To add Information activity, select Human Activities from the Activities pane on the left.
-
Drag and drop an Information activity to the Process Design area.
-
Right-click the Information activity in the Design area and select Activity Properties from the context menu.
-
Now the Activity Properties pane appears on the right side using which we need to configure the following:
-
Name of the activity: Specify a Name
-
The Actor to whom this information should be sent: Select the Actor to whom this activity will be assigned. For this example, we will send the information to the Actor who submitted the workflow. Click the icon edit in the Assign Actor(s) property. The Assign Actor(s) window pops up. We have to assign the Information task to the user who has alerted the workflow. For this, we have to specify a small expression: Id = Variable Variable.SubmittedBy.ID
-
Select the required provider from the Providers drop down.
-
From the first drop down, select Id.
-
Keep the operator as default "=".
-
From the next drop down, select Variable
-
In the next drop down, select Variable.SubmittedBy.ID and click the Add button as shown in the following image:
-
Click Update to save the property value.
-
-
The subject of the actual information.
-
Click edit near the Subject property to enter the subject for the Information which appears in the actor's Inbox.
-
To customize the Subject, we can use the Field controls. Select Variable from the first drop down. Select the variable we had declared in the Start activity from the second drop down that is, Variable.SOAVariable as shown below and click Append.
-
You will get the Subject line in this format:
-
Click Update and then the Save button in the Activity Properties pane to save all the data entered.
-
-
-
Now, we have to link all the activities that is, Start, SOA Execute1, and Display SOA Output.
Set the output value from the SOA Execute1 to Display SOA Output as "Successful".
Publish the SOAWorkflow
-
To publish the workflow, click the Publish option from the menu bar on the top.
A message box pops up indicating that the workflow has been published successfully.
-
On clicking Close you will be redirected to the page showing the Workflows list.
-
Run the published workflow. Select the listed workflow and right-click it.
-
Select the Publish and Test Run option from the context menu.
The Process execution view window appears showing the execution status. You will that notice the Start, SOA Execute1 and Display SOA output activities have been executed successfully.
Note: If the Status is "Execution Pending" in the Process execution window, then click the Refresh button to get the latest status.
You can also view the result value by clicking on any of the activities in the Process execution window and then clicking on the Variables tab.
View the Inbox
You have to view the information task assigned to the actor who alerted the workflow.
-
To see the activity in the Inbox, select the Inbox option from the Enterprise Console menu.
-
In the Inbox you can find the Display Web Service Data activity with the Subject "Welcome to SOA".
-
Click on the Information task in the Inbox to open a pop up details view for the task.
You have successfully created the SOAWorkflow.