Skip to main content

Allow WebService and POST HTTP form action calls to be context-aware

Article # 3048408 - Page views: 56


When calling a CaptureDocumentService api via WebService within a capture activity i.e. from a document type Validation form, we get an error that the document cannot be locked as our resource already has it locked

In order for the Capture API to be context-aware, a special header must be added to the request (this is done automatically for dotnet calls made from Capture activity forms)


A new "ContextHeader" property is added in Capture controls in Kofax TotalAgility Designer:


This new property is useful when calling Capture SDK (CaptureDocumentService) using web service references from custom DLL.
To make API calls context-aware, wecan consume the ContextHeader property and inject it into outgoing HTTP headers before making an API call.
Basic example:

var cds = new CaptureDocumentServiceClient(binding, new EndpointAddress("http://kta-server/TotalAgility/Services/Sdk/CaptureDocumentService.svc"));
using (var scope = new OperationContextScope(cds.InnerChannel))
    // Set special header to make sure API is executed in correct context
    // 'header' value is consumed from 'ContextHeader' property of Capture control 
    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
        new HttpRequestMessageProperty
            Headers =
                { "CaptureContextDataHeader" , header }
    // Call some API from CaptureDocumentService
    cds.DeletePages(sessionId, new CDSWS.ReportingData(), documentId, new CDSWS.PageIndexCollection { new CDSWS.PageIndex { Index = 0 } });

To pass the ContextHeader property from the activity form to the document type form, we can make use of a Global Variable and a same page action,


Add the same page action on the 'Select Document' event on the activity form



We can then use the Global Variable as an input to our custom api call on the document type form


Level of Complexity 



Applies to  

Product Version Build Environment Hardware
Kofax TotalAgility v7.10.0.4 +      




Article # 3048408
  • Was this article helpful?