This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.

Objective

The aim of this article is to give an example xml about how to start a workflow from a web service call.

Before You Begin

You must be familiar with the following:

1). XML

2). SOAPUi

How-to Steps

In this example we start an instance of a workflow using WCF call, and using SoapUi. The workflow has some dependant datafield(s) values and thus needs data assigned to these datafield(s) when the workflow instance is started.

The sample workflow assigns a task to a user specified on a datafield "UserToAssignTask".

The XML needs to be in the following structure:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:d1="http://schemas.k2.com/process/d1" xmlns:d11="http://schemas.k2.com/worklist/d1">
              <soapenv:Header/>
                     <soapenv:Body>
                             <d1:StartNewProcessInstance>
                                    <d1:processInstance Folio="TestTextFolio" FullName="K2WorkflowProject3\TestTransfer" >
                                           <d1:synchronous>false</d1:synchronous>
                                           <d1:DataField Name="UserToAssignTask">K2:Denallix\Bob</d1:DataField>
                                   </d1:processInstance>
                            </d1:StartNewProcessInstance>
                    </soapenv:Body>
</soapenv:Envelope>

In the example above, notice that the ProcessInstance xml is only closed after datafield(s) have been assigned values, not before. If it is closed before, the workflow will start but with no DataFields values, and as a result a workflow go into an "Error" state.

Below is an example of the malformed xml.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:d1="http://schemas.k2.com/process/d1" xmlns:d11="http://schemas.k2.com/worklist/d1">
              <soapenv:Header/>
                     <soapenv:Body>
                             <d1:StartNewProcessInstance>
                                    <d1:processInstance Folio="TestTextFolio" FullName="K2WorkflowProject3\TestTransfer" />
                                           <d1:synchronous>false</d1:synchronous>
                                           <d1:DataField Name="UserToAssignTask">K2:Denallix\Bob</d1:DataField>
                            </d1:StartNewProcessInstance>
                    </soapenv:Body>
</soapenv:Envelope>