Call methods from the TotalAgility SDK using custom code

When calling the Kofax TotalAgility SDK, the following options exist:

  • Use the KTA .NET SDK

  • Use the KTA WCF SDK

When the client is implemented in .NET, it is preferable to call the .NET SDK because the namespaces in the help match exactly with those the developer uses in the code. However, when the Kofax TotalAgility SDK is to be invoked from a non-.NET client, the Kofax TotalAgility WCF SDK must be used as the .NET SDK cannot be used.

To implement the .NET code for calling the KTA .NET SDK:

  1. To access the Kofax TotalAgility .NET SDK, add references to TotalAgility.Sdk.dll and Agility.Sdk.Model.dll assemblies. These methods are typically available at:

    <Installationfolder>\Agility.Server.Web\bin

    Example: C:\Program Files\Kofax\TotalAgility\Agility.Server.Web\bin

  2. In addition to the above DLLs, copy the following into the client's executing directory:

    • Agility.Server.Common.dll

    • Agility.Server.Core.Model.dll

    • Agility.Server.Integration.Common.dll

    • Agility.Server.Integration.Model.dll

    Note Not all of the assemblies listed above are invoked. Some of these are required due to dependencies.
  3. To enable communication with TotalAgility, open app.config (or web.config for Web application) and configure the settings:
    <appSettings>
        <add key="IsMultitenantDeployment" value="false"/>
        <add key="SdkServicesLocation" value="http://localhost/TotalAgility/Services/SDK"/>
      </appSettings>
    
    <bindings>
            <basicHttpBinding>
              <binding name="BasicHttpBinding_Service" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode=
                       "StrongWildcard"
                maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize=
                       "2147483647"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="TransportCredentialOnly">
                  <transport clientCredentialType="Windows" proxyCredentialType="None"
                    realm="" />
                  <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
              </binding>
            </basicHttpBinding>
          </bindings>
          <client>
            <endpoint name="SdkUserServiceEndpoint" 
                      binding="basicHttpBinding" 
                      bindingConfiguration="BasicHttpBinding_Service" 
                      contract="Agility.Sdk.Model.Interfaces.Services.IUserService"/>
          </client>
    
  4. To log on to Kofax TotalAgility, use the following code snippet.
    UserIdentity identity = new UserIdentity();
    identity.UserId = @"<domain_name>\<user_id>";
    identity.UnconditionalLogOn = true;
    identity.LogOnProtocol = 7;
    
    UserService userService = new UserService();
    Session session = userService.LogOn(identity);
    
  5. To call SDK for creating a job, create a new end point in app.config.

    The endpoint name must conform to the following format: Sdk<ServiceName>Endpoint. For example, the endpoint name for Job Service is: SdkJobServiceEndpoint.

    <endpoint name="SdkJobServiceEndpoint"
                      binding="basicHttpBinding"
                      bindingConfiguration="BasicHttpBinding_Service"
                      contract="Agility.Sdk.Model.Interfaces.Services.IJobService"/>
    

    Add the following code snippet:

    JobService jobService = new JobService();
    ProcessIdentity processIdentity = new ProcessIdentity();
    processIdentity.Name = "Process A";
    
    JobInitialization jobInitialisation = null;
    JobIdentity jobIdentity = jobService.CreateJob(session.SessionId, processIdentity,
     jobInitialisation);