How to Perform an Activity Using SOA
From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS
<keywords content="keywords"> soa, perform activity, execute activity, advance case </keywords>
Contents |
How to perform an activity from an external application
Overview
A common request is the possibility for users to advance their assigned activities via an external application, a mobile device, or a portal.
In Bizagi, we have this option as the possibility to use Bizagi's SOA layer (its web services) to send business information (approving, including comments, etc) into a certain activity of any Bizagi process ("perform it" from an external application).
This may be accomplished by using the web method called performActivity (or performActivityAsString) of the WorkflowEngineSOA web service, already included and published in every Bizagi project.
The performActivity and performActivityAsString web methods have the same functionality; their only difference is that performActivity receives an XML document while performActivityAsString receives a String with XML-formatted information.
View further information about the performActivity and performActivityAsString web method (input and output).
Example
This example will show how to perform the Register Vacation Request activity of the Vacation Request process from My first Process. (This documentation refers to Bizagis latest version) The example is no longer available in 9.1.x versions.
This activity has the following form:
The activity will be performed by including business information in the form.
To do this, it is important to be familiar with the data model. This process has a simple data model and all the data of the first activity is contained in the VacationRequest process entity.
Input XML
To perform the Register Vacation Request activity, the following XML is sent to the performActivity method:
<BizAgiWSParam> <ActivityData> <idCase>123</idCase> <taskName>Task1</taskName> </ActivityData> <Entities> <VacationRequest> <VacationStartingDate>2010-03-18T12:00:00-05:00</VacationStartingDate> <VacationEndingDate>2010-03-26T12:00:00-05:00</VacationEndingDate> <NumberOfOfficeDaysReques>6</NumberOfOfficeDaysReques> </VacationRequest> </Entities> </BizAgiWSParam>
Notice that in the tag <taskName> is necessary to input the task's name, not the display name.
The task name is looked up under the Properties of any given task from the Process Modeler view:
With this example XML, we will be performing the Register Vacation Request's activity from an external application, and including as well the business information by using the <Entities> tag. The performer for this activity would be the 'admon' user.
To change the performer, the tags <domain> and <userName> must be included after the <BizAgiWSParam> tag.
It is also possible to perform the activity without sending any business information to the form. For example:
<BizAgiWSParam> <domain>domain</domain> <userName>cindyj</userName> <ActivityData> <idCase>123</idCase> <taskName>Task1</taskName> </ActivityData> </BizAgiWSParam>
Bizagi's data model
Notice that it is always required to use the exact name of the elements, as was shown for the <taskName> tag, and never use the display name.
The first tag contained in the <Entities> element will be the name of the reference attribute at the application Entity (in this case App) which references your process entity.
Notice this naming is case-sensitive.
To learn about or review how is the business information expected in Bizagi's data model, you may make use of the Xml schema generation option in Bizagi.
The external application
Using a Windows Application to simulate the external application advancing the pending task of a given case (as shown in the next image), the necessary information is inputted and a button is clicked to invoke the perform activity to the Register Vacation Request's pending task.
In this example, we use a local Bizagi application with this URL:
http://biz-cindyj/MyFirstProcess/
Once the button is clicked, the activity is performed using Bizagi's SOA Layer and we will receive the response confirmation (output) from Bizagi. Bizagi will advance the process workflow so that the next activity is enabled.
Entering to the case detail in Bizagi's work portal, we will see that it will be in a state on which its pending activities are the next ones following the invoked one from the SOA layer.
To do this on a sample .Net project and environment, a Web Reference must be created (for this example the Web Reference name is MyFirstProcessWE) using this URL:
http://biz-cindyj/MyFirstProcess/webservices/WorkflowEngineSOA.asmx
The button's click-code will be:
private void button2_Click(object sender, EventArgs e) { try { string sStartingDate = XmlConvert.ToString(dateTimePicker1.Value, XmlDateTimeSerializationMode.Unspecified); string sSEndingDate = XmlConvert.ToString(dateTimePicker2.Value, XmlDateTimeSerializationMode.Unspecified); string sXml = "<BizAgiWSParam>"; sXml += "<ActivityData>"; sXml += "<idCase>" + textBox2.Text + "</idCase>"; sXml += "<taskName>Task1</taskName>"; sXml += "</ActivityData>"; sXml += "<Entities>"; sXml += "<VacationRequest>"; sXml += "<VacationStartingDate>" + sStartingDate + "</VacationStartingDate>"; sXml += "<VacationEndingDate>" + sSEndingDate + "</VacationEndingDate>"; sXml += "<NumberOfOfficeDaysReques>" + textBox1.Text + "</NumberOfOfficeDaysReques>"; sXml += "</VacationRequest>"; sXml += "</Entities>"; sXml += "</BizAgiWSParam>"; XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(sXml); MyFirstProcessWE.WorkflowEngineSOA ws = new MyFirstProcessWE.WorkflowEngineSOA(); XmlNode xn = ws.performActivity(xDoc); if (xn.SelectSingleNode("process/processError/errorCode") != null) { label6.Text = "ERROR:" + xn.SelectSingleNode("process/processError/errorMessage").InnerText; } else { label6.Text = "SUCCESS"; } } catch (Exception ex) { label6.Text = "ERROR: " + ex.Message; } finally { label6.Visible = true; } }
To view the considerations for Bizagi Enterprise JEE edition, review the next section.
Additional considerations
Take into account the considerations listed at Bizagi_SOA_layer_URL_and_considerations, to ensure the interoperability between different platform technologies (.Net, JEE).
Related Articles
- View detailed information about the performActivity and performActivityAsString web methods of Bizagi SOA Layer.
- View information about Bizagi's SOA Layer and its web methods.
- View how is any Entity's or process' data model presented through the Xml schema generation option in Bizagi.
<comments />