Legacy Workflow SOAP Web Services

This content applies to legacy components (such as K2 Studio and K2 for Visual Studio), legacy assemblies, legacy services or legacy functionality. If you have upgraded from K2 blackpearl 4.7 to K2 Five, these items may still be available in your environment. These legacy items may not be available in new installations of K2 Five. These legacy items may also not be available, supported, or behave as described, in future updates or versions of K2. Please see the legacy component support policy for more information about support for these components.

K2 Services provide legacy SOAP Web service (WS) endpoints for a portion of the SourceCode.Workflow.Client APIs.  Developers familiar with using the SourceCode.Workflow.Client APIs as locally referenced resources will be immediately productive accessing these same resources via WS endpoints.

The SourceCode.Workflow.Client Namespace documentation contains information on the underlying classes, properties, methods and sample code.  Reference this namespace when utilizing the WS endpoints.

Detailed information on service contracts, data contracts and operation contracts can be found in the endpoint Service Descriptions.

The .asmx service is intended for support of legacy protocols or platforms that cannot consume WCF-based services. It is not as extensive as the WCF/REST based services and will not be extended with additional functionality in future releases of K2.

URI – Service Description

{Service Root URI}?wsdl
e.g.
http://api.denallix.com:81/K2Services/WCF.asmx?wsdl

  • Service Root URI = {Scheme}{Server}:{Port}{Service Root}
    • Scheme = http:// or https:// if SSL is enabled (default)
    • Server = Server or Host Name of web site hosting K2 services
    • Port = Port of web site hosting K2 Services
    • Service Root = Virtual directory and service endpoint exposed by K2 Services.  The values for Service Root are configurable.  The defaults is:
      • /K2Services/WS.asmx

WS Methods

The following operations are supported by the WS.asmx endpoint.

  • ExecuteActionBySerial 
  • ExecuteActionByWorklistItem
  • OpenProcessInstance 
  • OpenWorklist 
  • OpenWorklistItem 
  • ReleaseWorklistItem
  • StartNewProcessInstance 
  • StartNewProcessInstanceScalar 
  • UpdateProcessInstance

Accessing Datafields returned by the WebService

The WS.asmx WebService consumes Datafields differenlty from the standard K2 API usage. For instance, in the satandard K2 API one can access the Datafield like this:
Datafield x = processInstance.Datafields[“MyDatafield”];

As WebServices maps everything as array objects it is not possible to follow the normal K2 API usage. The following example code demonstrates how to access the contents of a Datafield that has been returned using the WebService:

privatestaticvoid GetDataField() {
 //Create web service client to hook into K2 web services
 WSService.WS client = new WSService.WS();
 //Pass credentials in to get a process instance or item back from K2 for a specific user.
 client.Credentials = new NetworkCredential("[USERNAME]", "[PASSWORD]", "[DOMAIN]");
 WSService.WorklistItem item = client.OpenWorklistItem("[ITEMSERIALNO]", true);
 //Display the value returned in the data field specified.
 string datafieldValue = item.ProcessInstance.DataField.GetDataFieldByName("[DATAFIELDNAME]").Value;
}

/// <summary>
/// Extension Method to get a data field from a K2 process instance by passing in the name of the desired data field.
/// </summary>
/// <param name="dataFieldName">Name of desired K2 process instance data field.</param>
/// <returns>Returns a dataField object if it exists.</returns>
publicstatic WSService.DataField GetDataFieldByName(this WSService.DataField[] dataFields, string dataFieldName) {
 // Looping through the dataFields collection to search for a process instance data field based on the dataFieldName value passed in.
 foreach(WSService.DataField dataField in dataFields) {
   if (string.Equals(dataField.Name, dataFieldName, StringComparison.OrdinalIgnoreCase)) {
    // Return the data field if it is found in the collection so the application can work with it.
    return dataField;
   }
  }
  // Handle accordingly if a data field is not found in the collection.
 returnnull;
}

Populating Datafields or XMLFields

To enable Datafields/XMLfields to be populated, the settings in the web.config located in the K2Services folder needs to be changed:

<inclusions userExtendedProperties="False" hiddenFields=”FalsemaxWorklistItems=”0processDataFields=”TrueprocessXmlFields=”TrueactivityDataFields=”FalseactivityXMLFields=”False>