WCF Services

K2 Services provide Windows Communication Foundation (WCF) 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 WCF endpoints.

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

Watch a short video on how to use the K2 REST and WCF Services (Length 13 minutes)

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

For information on how to configure K2 Services for Claims Authentication support, go to KB001426.

URI – Service Description

{Service Root URI}?wsdl
http://api.denallix.com:81/K2Services/WCF.svc?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 are:
      • /K2Services/WCF.svc
      •  /K2Services/SyncWCF.svc

WCF Methods

The following operations are supported by the WCF.svc endpoint.

ICoreService

• WhoAmI() – returns User making the request

IIdentityService

  • GetAllUsers() – returns User[] of all the users
  • GetUser(string fqn) – returns User for specified parameters
  • SearchUsers(string username, string displayName, string e-mail, string manager) – returns User[] for specified parameters

IProcessNavigationService

  • OpenProcessInstance(string processInstanceId, bool piDataField, bool piXmlField) – returns a ProcessInstance for the specified process instance ID with or without data and XML fields
  • StartNewProcessInstance(ProcessInstance processInstance,  bool synchronous, bool actDataField, bool actXmlField, bool piDataField, bool piXmlField) – starts a process for the specified ProcessInstance and returns the updated ProcessInstance with or without data and XML fields
  • StartNewProcessInstanceScalar(string fullName, string folio, bool synchronous) – starts a process instance for the specified process definition name.  Returns the process instance ID as a long.
  • UpdateProcessInstance(ProcessInstance processInstance) – updates the specified ProcessInstance

IWorklistNavigationService

  • ExecuteActionBySerial(string serialNumber, string action, bool synchronous) – executes action for specified serial number
  • DelegateWorklistItem(string serialNumber, string destination) – performs the system action to delegate a task to the user specified as a Fully Qualified Name
  • RedirectWorklistItem(string serialNumber, string destination) – performs the system action to redirect a task to the user specified as a Fully Qualified Name
  • ReleaseWorklistItem(string serialNumber) - performs the system action to release a task
  • SleepWorklistItem(string serialNumber, string duration) – performs the system action to sleep a task based on the duration specified
    • Duration = (>0) – sleeps the item the amount of seconds specified
    • Duration = (0) – sleeps the item indefinitely
    • Duration = (<0, e.g. -1) – wakes the item
    • Duration = {DateTime} – sleeps the item until specified date time.  Standard DateTime with time zone is supported: http://www.w3.org/TR/xmlschema11-2/#dateTime
  • ExecuteActionByWorklistItem(WorklistItem item, string action, bool synchronous) – executes action for specified worklist item
  • OpenWorklist(bool actDataField, bool actXmlField, bool piDataField, bool piXmlField) – returns WorklistItem[] with or without data and XML fields
  • OpenWorklistFiltered(SourceCode.Worklist.Client.WorklistCriteria filter, bool actDataField, bool actXmlField, bool piDataField, bool piXmlField) – returns filtered and sorted WorklistItem[] with or without data and XML fields
  • OpenWorklistItem(string serialNumber, bool allocate, bool actDataField, bool actXmlField, bool piDataField, bool piXmlField) – returns WorklistItem for specified serial number with or without data and XML fields, optionally allocating the item to the current user
  • SearchForWorklistItems(string processFullName, string folio, bool actDataField, bool actXmlField, bool piDataField, bool piXmlField) – returns WorklistItem[] for specified process full name or folio with or with data and XML fields

SyncWCF Methods

The following operations are supported by the SyncWCF.svc endpoint.

ICoreService

  • WhoAmI() – returns User making the request

IIdentityService

  • GetAllUsers() – returns User[] of all the users
  • GetUser(string fqn) – returns User for specified parameters
  • SearchUsers(string username, string displayName, string e-mail, string manager) – returns User[] for specified parameters

ITaskService

  • GetTask(bool allocate, string serialNumber, bool actDataField, bool actXmlField, bool piDataField, bool piXmlField) – returns Task for the specified serial number with or without data and XML fields
  • GetTasks(bool actDataField, bool actXmlField, bool piDataField, bool piXmlField) – returns Task[] with or without data and XML fields
  • GetTasksFiltered(SourceCode.Worklist.Client.WorklistCriteria filter, bool actDataField, bool actXmlField, bool piDataField, bool piXmlField) – returns filtered and sorted Task[] with or without data and XML fields
  • UpdateTask(UpdateTask task, string Action, int ID, string serialNumber) - the Action here is "rl" to release the item, the ID is the process ID, and returns success or failure
  • UpdateTask(UpdateTask task) – updates the UpdateTask specified
  • UpdateTasks(UpdateTask[] tasks) – returns MultipleOperationResult for the UpdateTask[] specified

Filtering 

WCF Filtering example

WcfK2Services.WorklistNavigationServiceClient client = new WcfK2Services.WorklistNavigationServiceClient();
            WcfK2Services.Criteria criteria = new WcfK2Services.Criteria()
            {
                Filter = new []
                {
                    new WcfK2Services.CriteriaFilter()
                    {
                        Field = WcfK2Services.CriteriaField.ProcessFolio,
                        Comparison = WcfK2Services.CriteriaComparison.Equal,
                        Value = "Approve Customer",
                        ValueType = WcfK2Services.ValueType.String
                    },
                    new WcfK2Services.CriteriaFilter()
                    {
                        Logical = WcfK2Services.CriteriaLogical.And,
                        Field = WcfK2Services.CriteriaField.ProcessData,
                        SubField = "Customer Name",
                        Comparison = WcfK2Services.CriteriaComparison.Like,
                        Value = "*Mary*",
                        ValueType = WcfK2Services.ValueType.String
                    }
                },
                Sort = new []
                {
                    new WcfK2Services.CriteriaSort()
                    {
                        Field = WcfK2Services.CriteriaField.ProcessStartDate,
                        Order = WcfK2Services.CriteriaSortOrder.Ascending
                    }
                }
            };

            WcfK2Services.WorklistItem[] items = client.OpenWorklistFiltered(criteria, false, false, false, false);