Legacy Workflow SOAP Web Services

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

WS Methods

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

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>

K2 blackpearl Developers Reference4.7
Video Links Learn Support
No videos found for this article
K2 on YouTube
No Additional links found for this article
No self-learning content for this article
Try some scenarios...
No relevant support links available for this article