Overview

The Ephesoft Transact web services API provides a simple method for real-time integration and exposure of Ephesoft processes to external applications. This allows developers to embed and employ advanced capture capabilities and technologies in content management systems and other workflows.

Ephesoft Transact web services support the OpenAPI standard, and the Ephesoft Transact Web Services Explorer utilizes the Swagger interface to enable documentation and testing for Ephesoft Transact web services. Web services that return XML responses can be tested directly in the Swagger interface, but due to a limitation of the Swagger interface, web services that return non-XML responses cannot. Refer to the Swagger/OpenAPI Capabilities section of each web service for information about whether a web service supports being tested directly in the Swagger interface or not. All Ephesoft Transact web services, including those that can’t be tested in the Swagger interface, can still be tested in other web service testing tools, such as Postman.

This document provides a brief description of each web service followed by a code sample showing how the web service can be used.  All code samples are written in Java and utilize the Apache Commons HttpClient library.

Web services on this page are grouped into the following sections:

Authentication

When Ephesoft Transact web services are used in an API development tool like Postman or Swagger, basic authentication must be provided in the http request header. For example:

Authorization:Basic ephesoft:demo (username and password should be encoded in Base64)

When Ephesoft Transact web services are used in Java code, client call authentication can be handled like this:

Credentials defaultcreds = new UsernamePasswordCredentials("username", "password");
client.getState().setCredentials(new AuthScope("serverName", 8080), defaultcreds);

Batch Class Management Web Services

copyBatchClass

This web service creates a copy of an existing batch class.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/batchClass/copyBatchClass

Sample Client Code Utilizing Apache Commons HttpClient
private static void createBatchClass() {
    HttpClient client = new HttpClient();
    String url = "http://{serverName}:{port}/dcma/rest/batchClass/copyBatchClass";
    PostMethod mPost = new PostMethod(url);
    // Adding Input XML file for processing
    File file = new File("C:\\sample\\Input.xml");
    Part[] parts = new Part[1];
    try {
        parts[0] = newFilePart(file.getName(), file);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        }
        else if(statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

copyDocumentType

This web service copies an existing document type to create a new document type in the same batch class.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/batchClass/copyDocumentType

Sample Client Code Utilizing Apache Commons HttpClient

private static void copyDocumentType() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/batchClass/copyDocumentType";
    PostMethod mPost = new PostMethod(url);
    // Adding Input XML file for processing
    File file = new File("C:\\sample\\Input.xml");
    Part[] parts = new Part[1];
    try {
        parts[0] = new FilePart(file.getName(), file);
        MultipartRequestEntity entity = newMultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody. 
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

documentTypeCreator

This web service creates a new document type.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/batchClass/documentTypeCreator

Sample Client Code Utilizing Apache Commons HttpClient

private static void createDocumentType() {
    HttpClient client = new HttpClient();
    String url = “http: //localhost:8080/dcma/rest/batchClass/documentTypeCreator“; PostMethod mPost = new PostMethod(url);
    // Adding Input XML file for processing
    File file = new File(“C: \\sample\\ Input.xml”);
    Part[] parts = new Part[1];
    try {
        parts[0] = newFilePart(file.getName(), file);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println(“Web service executed successfully.”);
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + ” ** * ”+responseBody);
        }
        else if(statusCode == 403) {
            System.out.println(“Invalid username / password.”);
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println(“File not found
            for processing.”);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

exportBatchClass

This web service exports a batch class.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/exportBatchClass

Sample Client Code Utilizing Apache Commons HttpClient

private static void exportBatchClass() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/exportBatchClass";
    PostMethod mPost = new PostMethod(url);
    mPost.addParameter("identifier", "BC1");
    mPost.addParameter("lucene-search-classification-sample", "true");
    mPost.addParameter("image-classification-sample", "false");
    int statusCode;
    try {
        statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Batch class exported successfully");
            InputStream in = mPost.getResponseBodyAsStream();
            File f = new File("C:\\sample\\serverOutput.zip");
            FileOutputStream fos = new FileOutputStream(f);
            try {
                byte[] buf = newbyte[1024];
                int len = in .read(buf);
                while (len > 0) {
                    fos.write(buf, 0, len);
                    len = in .read(buf);
                }
            } finally {
                if (fos != null) {
                    fos.close();
                }
            }
        }
        else if(statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

getAllModulesWorkflowNameByBatchClass

This web service returns the module names and module workflow names for the specified batch class.

Request Method: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/getAllModulesWorkflowNameByBatchClass/{batchClassIdentifier}

Sample Client Code Utilizing Apache Commons HttpClient

private static void getAllModulesWorkflowNameByBatchClass() {
    HttpClient client = new HttpClient();
    // URL path to be hit for getting the mdoule workflow name of the specified batch class identifier
    String url = "http://localhost:8080/dcma/rest/getAllModulesWorkflowNameByBatchClass/BC1";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

getBatchClassFields

This web service returns the batch class fields of the supplied batch class identifier. The batch class fields are only returned if the batch class is accessible to the user.

Request Method: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/getBatchClassFields/{batchClassIdentifier}


getBatchClassForRole

This web service retrieves a list of all batch classes accessible to the specified user role.

Request Method: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/getBatchClassForRole/{role}

Sample Client Code Utilizing Apache Commons HttpClient

private static void getBatchClassForRole() {
    HttpClient client = new HttpClient();
    // URL path to be hit for getting the batch class list having accessed by the role specified.
    String url = "http://localhost:8080/dcma/rest/getBatchClassForRole/admin";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

getBatchClassList

This web service returns a list of all batch classes accessible by the authenticated user.

Request Method: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/getBatchClassList

Sample Client Code Utilizing Apache Commons HttpClient

private static void getBatchClassList() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/getBatchClassList";
    GetMethod mGet = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(mGet);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mGet.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        }
        else if(statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mGet.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mGet != null) {
            mGet.releaseConnection();
        }
    }
}

getRoles

This web service retrieves all roles for a given batch class.

Request Method: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/getRoles/{batchClassIdentifier}

Sample Client Code Utilizing Apache Commons HttpClient

private static void getRoles() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/getRoles/BC1";
    GetMethod mGet = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(mGet);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mGet.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        }
        else if(statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mGet.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mGet != null) {
            mGet.releaseConnection();
        }
    }
}

importBatchClass

This web service imports a batch class into Ephesoft Transact.

Request Method: POST

Web Service URL:  http://{serverName}:{port}/dcma/rest/importBatchClass

Sample Client Code Utilizing Apache Commons HttpClient

private static void importBatchClass() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/importBatchClass";
    PostMethod mPost = new PostMethod(url);
    mPost.setDoAuthentication(true);
    // Input XML for adding parameter.
    File file1 = new File("C:\\sample\\importbatchclass.xml");
    // Input zip file for importing batch class.
    File file2 = new File("C:\\sample\\BC1_050712_1714.zip");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Batch class imported successfully");
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.out.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

learnFile

This web service will learn all the files present in the search classification and image classification learning folders of the batch class. This web service supports using a PDF file’s EText layer for OCR, provided that the batch class has been configured accordingly to support that processing method.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/batchClass/learnFile/{BatchClassIdentifier}

Sample Client Code Utilizing Apache Commons HttpClient

private static void fileLearningService() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/batchClass/learnFile/{BatchClassIdentifier}";
    PostMethod mPost = new PostMethod(url);
    try {
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

learnFuzzyDatabase

This web service performs database learning for the Fuzzy DB feature. The database table to be learned is based on the ‘Document Fuzzy’ and ‘Field Fuzzy’ configurations defined inside the document type of the batch class. This web service emulates clicking the LearnDB command in the Transact user interface.

Request Method: POST

Web Service URL: http://<hostname>:<port>/dcma/rest/batchClass/learnFuzzyDatabase

Sample Client Code Utilizing Apache Commons HttpClient

private static void learnFuzzyDatabase() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/batchClass/learnFuzzyDatabase";
    PostMethod mPost = new PostMethod(url);
    // adding file for sending
    Part[] parts = new Part[4];
    try {
        parts[0] = new StringPart("batchClassIdentifier", "BC1");
        parts[1] = new StringPart("documentType", "Invoice-Table");
        parts[2] = new StringPart("groupNames", "*");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

uploadLearningFile

This web service uploads learning files for one or more document types in a batch class. As opposed to the uploadLearnFile web service, which automatically places pages in the appropriate first/middle/last folders based on their positions in the uploaded files, this web service allows the developer to choose the exact folder (first, middle or last) where individual pages will be placed. The files are uploaded to one or more of the following folders depending on the ‘learning_type’ value defined in the web service parameters file.

Request Method:  POST

Web Service URL: http://{serverName}:{port}/dcma/rest/batchClass/uploadLearningFile

Sample Client Code Utilizing Apache Commons HttpClient

private static void learnFile() {
    HttpClient client = newHttpClient();
    String url = "http://localhost:8080/dcma/rest/batchClass/uploadLearningFile";
    PostMethod mPost = new PostMethod(url);
    // Adding Input XML file for processing 
    File file = new File("C:\\sample\\Input.xml");
    File file1 = new File("C:\\sample\\first.tif");
    File file2 = new File("C:\\sample\\second.tif");
    Part[] parts = new Part[number of files need to be uploaded];
    try {
        parts[0] = new FilePart(file.getName(), file);
        parts[1] = new FilePart(file1.getName(), file1);
        parts[2] = new FilePart(file2.getName(), file2);
        parts[n] = new FilePart(filen.getName(), filen);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        // send post request to server
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody. 
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

uploadLearnFiles

This web service uploads files to the specified learning folder of a batch class based on the specified learning type. This web service approximates the process of learning files through the Transact user interface, where the user only needs to supply the batch class, document type, learning type, and files, and the web services will distribute the individual pages into the appropriate first, middle and last page folders in the operating system automatically.

Request Method: POST

Web Service URL:  http://{serverName}:{port}/dcma/rest/batchClass/uploadLearnFiles


Batch Instance Management Web Services

AddUserRolesToBatchInstance

This web service adds a user role to a batch instance.

Request Method: GET

Web Service URL:  http://{serverName}:{port}/dcma/rest/AddUserRolesToBatchInstance/{batchInstanceIdentifier}/{userRole}

Sample Client Code Utilizing Apache Commons HttpClient

private static void addUserRolesToBatchInstance() {
    HttpClient client = new HttpClient();
    // URL path to be hit for adding user roles to batch instance identifier
    String url = "http://localhost:8080/dcma/rest/addUserRolesToBatchInstance/BI45/admin";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

BatchInstanceList

This web service returns a list of batch instances with the specified status. If the user is the super admin user, all batch instances with the specified status will be returned. If the user is not the super admin user, only batch instances that can be accessed by the user will be returned. The following details will be returned for each batch instance: batch name, executed modules, local folder, review operator, batch identifier, drop folder.

Request Method: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/BatchInstanceList/{status}

Sample Client Code Utilizing Apache Commons HttpClient

private static void getBatchInstanceList() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/BatchInstanceList/RUNNING";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

deleteBatchInstance

This web service is used to delete a batch instance. The batch instance will be deleted only if the batch instance is not locked by any user, and is in one of the following states: Error, Running, Ready for Review, or Ready for Validation. Note that the user must be authenticated and must have access to the batch instance being deleted.

Request Method: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/deleteBatchInstance/{identifier}

Sample Client Code Utilizing Apache Commons HttpClient

private static void deleteBatchInstance() {
    HttpClient client = new HttpClient();
    // User can only delete batch instances with statuses of ERROR, READY_FOR_REVIEW, READY_FOR_VALIDATION, or RUNNING
    String url = "http://localhost:8080/dcma/rest/deleteBatchInstance/BI1";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

getBatchInstanceForRole

This web service retrieves the list of batch instances accessible to a particular role.

Request Method: GET

Web Service URL:  http://{serverName}:{port}/dcma/rest/getBatchInstanceForRole/{role}

Sample Client Code Utilizing Apache Commons HttpClient

private static void getBatchInstanceForRole() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/getBatchInstanceForRoles/admin";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

Batch Instance Processing Web Services

advancedBarcodeExtraction

This web service performs barcode extraction on the input document based on the configuration options provided in the parameters.xml file. The settings for the ADVANCED_BARCODE_EXTRACTION plugin for the supplied batch class identifier are retrieved and used to perform the extraction.

Request Method: POST

Web Service URL: http://<HOSTNAME>:8080/dcma/rest/advancedBarcodeExtraction

Sample Client Code Utilizing Apache Commons HttpClient

private static void advancedBarcodeExtraction() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/advancedBarcodeExtraction";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\sample.xml");
    // adding xml file for taking input
    File file2 = new File("C:\\sample\\US-Invoice.tif");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            System.out.println(mPost.getResponseBodyAsString());
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

advancedUploadBatch

This web service uploads a new batch to the identified batch class’s drop folder.

Request Type: POST

Request URL: {ProtocolType}://{ServerIP}:{ServerPort}/dcma/rest/advancedUploadBatch

Sample URL: http://localhost:8080/dcma/rest/advancedUploadBatch

 

Sample Input XML

<Upload_Batch> 
    <BatchClassIdentifier>BC1</BatchClassIdentifier> 
    <BatchClassFields> 
       <BatchClassField> 
           <Name>Test1</Name> 
           <Value>123</Value> 
       </BatchClassField> 
       <BatchClassField> 
           <Name>Test2</Name> 
           <Value>456</Value> 
       </BatchClassField> 
    </BatchClassFields> 
    <BatchInstanceName>SampleBatch</BatchInstanceName> 
    <BatchDescription>SampleDesc</BatchDescription> 
    <BatchPriority>20</BatchPriority> 
</Upload_Batch>

Sample Client Code Utilizing Apache Commons HttpClient

HttpClient client = new HttpClient();
String url = "http://localhost:8080/dcma/rest/advancedUploadBatch";
PostMethod mPost = new PostMethod(url);
File file1 = new File("C:\\sample\\advancedUploadBatch.xml");
File file2 = new File("C:\\sample\\US-Invoice.tiff");
Part[] parts = new Part[2];
try {
    // Input XML
    parts[0] = new FilePart(file1.getName(), file1);
    // File for processing
    parts[1] = new FilePart(file2.getName(), file2);
    MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
    mPost.setRequestEntity(entity);
    int statusCode = client.executeMethod(mPost);
    if (statusCode == 200) {
        System.out.println("Web service executed successfully.");
        String responseBody = mPost.getResponseBodyAsString();
        System.out.println(statusCode + " *** " + responseBody);
    } else if (statusCode == 403) {
        System.out.println("Invalid username/password.");
    } else {
        System.out.println(mPost.getResponseBodyAsString());
    }
} catch (FileNotFoundException e) {
    System.err.println("File not found for processing.");
} catch (IOException e) {
    e.printStackTrace();
} finally {
    if (mPost != null) {
        mPost.releaseConnection();
    }
}

barcodeExtraction

This web service performs barcode extraction on the input document based on the configuration options provided in the parameters.xml file. The settings for the ADVANCED_BARCODE_EXTRACTION plugin for the supplied batch class identifier are retrieved and used to perform the extraction.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/barcodeExtraction

Sample Client Code Utilizing Apache Commons HttpClient

private static void barcodeExtraction() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/barcodeExtraction";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\sample.tif");
    // adding xml file for taking input
    File file2 = new File("C:\\sample\\WebServiceParams-barcodeExtraction.xml");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            System.out.println(mPost.getResponseBodyAsString());
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

checkWSStatus

This web service queries the current status of the initiateOcrClassifyExtract web service.

Service Request: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/checkWSStatus

Sample Client Code Utilizing Apache Commons HttpClient

private static void checkWSStatus() {
    HttpClient client = new HttpClient();
    String url = " http://localhost:8080/dcma/rest/checkWSStatus?ocrToken=1233232323 ";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

classifyBarcodeImage

This web service is used to classify the supplied image using a barcode according to the specified batch class. The image file should contain a barcode and the barcode value should represent a document type that exists in the batch class.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/classifyBarcodeImage

Sample Client Code Utilizing Apache Commons HttpClient

private static void classifyBarcodeImage() {
    HttpClient client = new HttpClient();
    String url = "http://locahost:8080/dcma/rest/classifyBarcodeImage";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\US-Invoice.tif");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new StringPart("batchClassId", "BC1");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + "  ***  " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

classifyHocr

This web service classifies the input HOCR.xml according to the batch class identifier provided. The appropriate classification and assembly plugins must be configured in the batch class. Document learning must be performed on the batch class before the web service is used. If the batch class doesn’t have the required plugins configured, the web service will not work.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/classifyHocr

Sample Client Code Utilizing Apache Commons HttpClient

private static void classifyHocr() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/classifyHocr";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\US-Invoice.html");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new StringPart("batchClassId", "BC1");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully..");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

classifyImage

This web service allows developers to classify documents from third party applications without creating batch instances. It performs layout-based classification based on the samples provided in the batch class and returns the document type. The input file to be classified must be a single-page TIFF file. This web service depends on the CREATE_THUMBNAILS, CLASSIFY_IMAGES and DOCUMENT_ASSEMBLER plugins. If the batch class does not contain these plugins the web service will not work.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/classifyImage

Sample Client Code Utilizing Apache Commons HttpClient

private static void classifyImage() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/classifyImage";
    PostMethod mPost = new PostMethod(url);
    // Adding tif file for processing
    File file1 = new File("C:\\sample\\US-Invoice.tif");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        // Adding parameter for batchClassId
        parts[1] = new StringPart("batchClassId", "BC1");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully..");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password..");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing..");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

classifyMultiPageHocr

This web service classifies multiple HOCR.xml files using the batch class identifier provided. The batch class depends on the SEARCH_CLASSIFICATION and DOCUMENT_ASSEMBLER plugins. Document learning must have been performed previously in the batch class.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/classifyMultiPageHocr

Sample Client Code Utilizing Apache Commons HttpClient

private static void classifyMultiPageHocr() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/classifyMultiPageHocr";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("D:\\sample\\New folder.zip");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new StringPart("batchClassId", "BC1");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        String responseBody = mPost.getResponseBodyAsString();
        System.out.println(statusCode + "***" + responseBody);
        mPost.releaseConnection();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

createHOCRforBatchClass

This web service generates HOCR.xml files for TIFF or PDF files.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/batchClass/createHOCRforBatchClass


Sample Client Code Utilizing Apache Commons HttpClient

private static void createHOCRXML() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/batchClass/createHOCRforBatchClass";
    PostMethod mPost = new PostMethod(url);
    // Adding Input XML file for processing
    File file = new File(“C:\\sample\\Input.xml”);
    File imageFile = new File(“C:\\sample\\SampleImage.tif”);
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file.getName(), file);
        parts[1] = new FilePart(imageFile.getName(), imageFile);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println(“Web service executed successfully.”);
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

createOCR

This web service will create an HOCR.xml file for the provided image file. Tesseract, Nuance and RecoStar all support conventional OCR processes where a non-TIFF image is converted to TIFF and then OCR’d accordingly. When RecoStar is used as the OCR engine, the EText layer of a PDF file can be used for OCR purposes if the RSP file has ExtractFromEText chosen as the processing mode. If a PNG or TIFF file is processed by the RecoStar OCR engine using an ExtractFromEText RSP file, a blank HOCR.xml file will be returned.

This web service supports using a PDF file’s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/createOCR


Sample Client Code Utilizing Apache Commons HttpClient

private static void createOCR() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/createOCR";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\sample1.tif");
    File file2 = new File("C:\\sample\\WebServiceParams.xml");
    File file3 = new File("C:\\sample\\Fpr.rsp");
    Part[] parts = new Part[3];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        parts[2] = new FilePart(file3.getName(), file3);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            InputStream in = mPost.getResponseBodyAsStream();
            // saving result generated.
            File outputFile = new File("C:\\sample\\serverOutput.zip");
            FileOutputStream fos = new FileOutputStream(outputFile);
            try {
                byte[] buf = newbyte[1024];
                int len = in .read(buf);
                while (len > 0) {
                    fos.write(buf, 0, len);
                    len = in .read(buf);
                }
            } finally {
                if (fos != null) {
                    fos.close();
                }
            }
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

decryptBatchInstanceHocrXml

This web service decrypts an HOCR.xml file in a batch instance. When a batch is executed in an encrypted batch class, the HOCR.xml files created for the image files are also encrypted. The name of the HOCR.xml file and the batch instance identifier are passed in as parameters.

Web Service URL: http://{serverName}:{port}/dcma/rest/decryptBatchInstanceHocrXml

Request Method: POST

Sample Client Code Utilizing Apache Commons HttpClient

private static void decryptBatchInstanceHocrXml() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/decryptBatchInstanceHocrXml";
    PostMethod mPost = new PostMethod(url);
    mPost.setDoAuthentication(true);
    Part[] parts = new Part[2];
    try {
        parts[0] = new StringPart("hocrFileName", "BI3_0_HOCR.xml");
        parts[1] = new StringPart("batchInstanceIdentifier", "BI3");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("HOCR  XML decrypted successfully");
            System.out.println(mPost.getResponseBodyAsString());
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.out.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

decryptBatchXml

This web service decrypts an encrypted batch.xml file (generally found in the final drop folder of a batch instance). Encrypted batch.xml files can only be decrypted on Transact servers that use the same encryption keys as the server that originally encrypted the batch.xml file.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/decryptBatchXml

Sample Client Code Utilizing Apache Commons HttpClient

private static void decryptBatchXml() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/decryptBatchXml";
    PostMethod mPost = new PostMethod(url);
    mPost.setDoAuthentication(true);
    File file1 = new File("F:\\Ephesoft\\SharedFolders\\BC5\\Final-drop-folder\\BI2\\BI2_batch.xml");
    Part[] parts = new Part[1];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Batch XML decrypted successfully");
            System.out.println(mPost.getResponseBodyAsString());
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.out.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

decryptLuceneClassificationHocrXml

This web service decrypts an HOCR.xml file in the lucene-search-classification-sample folder within the batch class folder in the SharedFolders area.

Web Service URL: http://{serverName}:{port}/dcma/rest/decryptLuceneClassificationHocrXml

Request Method: POST

Sample Client Code Utilizing Apache Commons HttpClient

private static void decryptLuceneClassificationHocrXml() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/decryptLuceneClassificationHocrXml";
    PostMethod mPost = new PostMethod(url);
    mPost.setDoAuthentication(true);
    // Input zip file for importing batch class.
    Part[] parts = new Part[4];
    try {
        parts[0] = new StringPart("hocrFileName", "US-Invoice_HOCR.xml");
        parts[1] = new StringPart("batchClassIdentifier", "BC5");
        parts[2] = new StringPart("pageType", "First");
        parts[3] = new StringPart("documentType", "US Invoice");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("HOCR  XML decrypted successfully");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.out.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

decryptTestHocrXml

This web service decrypts an HOCR.xml file in one of the test folders within the batch class. Test folders that can be used with the web service are test-advanced-extraction, test-classification, test-extraction and test-table.

Web Service URL: http://{serverName}:{port}/dcma/rest/decryptTestHocrXml

Request Method: POST

Sample Client Code Utilizing Apache Commons HttpClient

private static void decryptTestHocrXml() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/decryptTestHocrXml";
    PostMethod mPost = new PostMethod(url);
    mPost.setDoAuthentication(true);
    Part[] parts = new Part[4];
    try {
        parts[0] = new StringPart("hocrFileName", "US-Invoice-0000_HOCR.xml");
        parts[1] = new StringPart("batchClassIdentifier", "BC5");
        parts[2] = new StringPart("testType", "table");
        parts[3] = new StringPart("documentType", "US Invoice");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("HOCR  XML decrypted successfully");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.out.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

extractFieldFromHocr

This web service executes key-value extraction for the requested field based on key-value rules defined in the batch class.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/extractFieldFromHocr

Sample Client Code Utilizing Apache Commons HttpClient

private static void extractFieldFromHocr() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/extractFieldFromHocr";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\Application-Checklist-hocr.xml");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        // Adding field value for extracting Key Value Pattern.
        parts[1] = new StringPart("fieldValue", "APPLICATION");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

extractFields

This web service provides multiple ways to perform extraction. The header parameter “extractionAPI” specifies the type of extraction to use.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/extractFields

Sample Client Code Utilizing Apache Commons HttpClient (Using the REGULAR_REGEX_EXTRACTION Option)

private static void extractFields() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/extractFields";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\input\\sample1.html");
    // adding xml file for taking input
    File file2 = new File("C:\\sample\\input\\WebServiceParams.xml");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        // Pass the name of extraction api that is to be used: BARCODE_EXTRACTION, RECOSTAR_EXTRACTION, REGULAR_REGEX_EXTRACTION, KV_EXTRACTION, FUZZY_DB, NUANCE_EXTRACTION
        Header header = new Header("extractionAPI", "REGULAR_REGEX_EXTRACTION");
        mPost.addRequestHeader(header);
        mPost.setRequestEntity(entity);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            System.out.println(mPost.getResponseBodyAsString());
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

extractFieldsUsingRegex

This web service extracts values and coordinates based on regular expressions defined for all fields of a particular document type of a particular batch class.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/extractFieldsUsingRegex

Sample Client Code Utilizing Apache Commons HttpClient

private static void extractFieldsUsingRegex() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/extractFieldsUsingRegex";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\sample1.xml");
    File file2 = new File("C:\\sample\\WebServiceParams.xml");
    Part[] parts = new Part[3];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        parts[2] = new StringPart(“hocrFileName”, file1.getName());
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            System.out.println(mPost.getResponseBodyAsString());
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

extractFixedForm

This web service provides two different processing options for extracting fixed-form data. Different XML parameter input file formats are needed depending on the option chosen.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/extractFixedForm

Sample Client Code Utilizing Apache Commons HttpClient

private static void extractFixedForm() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/extractFixedForm";
    PostMethod mPost = new PostMethod(url);
    // adding file for sending
    File file1 = new File("C:\\sample\\fixedForm.xml");
    File file2 = new File("C:\\sample\\Image.tif");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost  != null) {
            mPost.releaseConnection();
        }
    }
}

extractFuzzyDB

This web service extracts index field information using the Fuzzy Database Lookup feature (based on the ‘Document Fuzzy’ configurations).

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/extractFuzzyDB

Sample Client Code Utilizing Apache Commons HttpClient

private static void extractFuzzyDB() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/extractFuzzyDB";
    PostMethod mPost = new PostMethod(url);
    File file = new File("C:\\sample\\Application-Checklist_000-hocr.xml");
    Part[] parts = new Part[4];
    try {
        parts[0] = new FilePart(file.getName(), file);
        parts[1] = new StringPart("documentType", "Application-Checklist");
        parts[2] = new StringPart("batchClassIdentifier", "BC1");
        parts[3] = new StringPart("hocrFile", "Application-Checklist_000-hocr.xml");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

extractFieldsForFuzzyDB

This web service extracts index field values utilizing both document- and field-level fuzzy database configurations.

Request Method: POST

Web Service URL: http://<HOSTNAME>:8080/dcma/rest/extractFieldsForFuzzyDB

Sample Client Code Utilizing Apache Commons HttpClient

private static void extractFieldsForFuzzyDB() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/extractFieldsForFuzzyDB";
    PostMethod mPost = new PostMethod(url);
    File webServInputFile = new File("C:\\sample\\FuzzyDBExtract_Input.xml");
    File hocrZipFile = new File("C:\\sample\\HOCR_XML.zip");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(webServInputFile.getName(), webServInputFile);
        parts[1] = new FilePart(hocrZipFile.getName(), hocrZipFile);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

extractKV

This web service extracts the document-level fields using key-value extraction rule properties specified in the parameters.xml file, using an HOCR.xml file as input. If the key-value pattern does not find a match in the HOCR.xml file, empty document-level fields will be created. For best results we recommend that you test the configuration options in the Transact user interface before building the configuration files for use with the web service.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/extractKV

Sample Client Code Utilizing Apache Commons HttpClient

private static void extractKV() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/extractKV";
    PostMethod mPost = new PostMethod(url);
    File f1 = new File("C:\\sample\\extractKV.xml");
    File f2 = new File("C:\\sample\\Application-Checklist-hocr.xml");
    Part[] parts = new Part[3];
    try {
        parts[0] = new FilePart(f1.getName(), f1);
        parts[1] = new FilePart(f2.getName(), f2);
        parts[2] = new StringPart("hocrFileName", f2.getName());
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + "  ***  " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

ExtractKVForDocumentType

This web service performs key-value extraction on an HOCR.xml file. The batch class ID and document type identified in the parameters.xml file are used to identify the key-value extraction rules that will be executed.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/batchClass/ExtractKVForDocumentType

Sample Client Code Utilizing Apache Commons HttpClient

private static void performKeyValueExtraction() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/batchClass/ExtractKVForDocumentType";
    PostMethod mPost = new PostMethod(url);
    File file = new File("C:\\sample\\Input.xml");
    File hocrZipFile = new File("C:\\sample\\Input_HOCR.zip");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file.getName(), file);
        parts[1] = new FilePart(hocrZipFile.getName(), hocrZipFile);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

initiateOcrClassifyExtract

This web service performs extraction on the supplied documents. The extraction plugins are retrieved from the batch class corresponding to the supplied batch class identifier, and classification and extraction will be performed based on those plugins. If the document type is provided as a parameter, classification will be skipped, and only extraction will be performed.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/initiateOcrClassifyExtract

Checklist
1. Extraction would be done only if Extraction module is configured for the particular batch class
2. Extraction would be performed only for the plugins which have extraction switch ON in batch class configuration.

Sample Client Code Utilizing Apache Commons HttpClient

private static void initiateOcrClassifyExtract() {
    HttpClient client = new HttpClient();
    Credentials defaultcreds = new UsernamePasswordCredentials(“username”, “password”);
    client.getState().setCredentials(new AuthScope(“serverName”, 8080), defaultcreds);
    client.getParams().setAuthenticationPreemptive(true);
    String url = "http://localhost:8080/dcma/rest/ initiateOcrClassifyExtract";
    PostMethod mPost = new PostMethod(url);
    // Adding HTML file for processing
    File file1 = new File("C:\\sample\\US-Invoice.tiff");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        // Adding parameter for batchClassIdentifier
        parts[1] = new StringPart("batchClassIdentifier", "BC1");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully..");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password..");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing..");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

keywordClassification

This web service classifies images into documents based on key-value page process rules (both page-level fields and classification rules). If classification is successful an XML object containing all documents is sent back as a response. If the KV_PAGE_PROCESS plugin is not configured the web service will return an error code.

This web service supports using a PDF file’s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/keywordClassification


ocrClassify

This web service performs OCR and classification on the provided documents.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/ocrClassify


ocrClassifyExtract

This web service performs classification and extraction on the supplied documents. Classification and extraction are performed based on the plugin configurations of the batch class identifier supplied. This web service supports using a PDF file’s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/ocrClassifyExtract

Sample Client Code Utilizing Apache Commons HttpClient

private static void ocrClassifyExtract() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/ocrClassifyExtract";
    PostMethod mPost = new PostMethod(url);
    // Adding HTML file for processing
    File file1 = new File("C:\\sample\\US-Invoice.tiff");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        // Adding parameter for batchClassIdentifier
        parts[1] = new StringPart("batchClassIdentifier", "BC1");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully..");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password..");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing..");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

OcrClassifyExtractSearchablePDF

This web service performs OCR, classification and extraction on the input documents, creating searchable PDF files and a batch.xml file containing the extraction results. Classification and extraction will be performed based on the plugins configured in the batch class.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/OcrClassifyExtractSearchablePDF

Sample Client Code Utilizing Apache Commons HttpClient

private static void OcrClassifyExtractSearchablePDF() {
    HttpClient client = new HttpClient();
    Credentials defaultcreds = new UsernamePasswordCredentials("ephesoft", "demo");
    client.getState().setCredentials(new AuthScope("localhost", 8080), defaultcreds);
    client.getParams().setAuthenticationPreemptive(true);
    String url = "http://localhost:8080/dcma/rest/OcrClassifyExtractSearchablePDF";
    PostMethod mPost = new PostMethod(url);
    // Adding HTML file for processing
    File file1 = new File("C:\\sample\\US-Invoice.tif");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        // Adding parameter for batchClassIdentifier
        parts[1] = new StringPart("batchClassIdentifier", "BC5");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Batch class exported successfully");
            InputStream in = mPost.getResponseBodyAsStream();
            File f = new File("C:\\sample\\Output.zip");
            FileOutputStream fos = new FileOutputStream(f);
            try {
                byte[] buf = new byte[1024];
                int len = in .read(buf);
                while (len > 0) {
                    fos.write(buf, 0, len);
                    len = in .read(buf);
                }
            } finally {
                if (fos != null) {
                    fos.close();
                }
            }
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.out.println("File not found for processing..");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

restartAllBatchInstance

This web service restarts all batch instances with states of Ready for Review or Ready for Validation. The RestartAll switch must be set to TRUE in the properties file for this web service to work.

Request Method: GET

Web Service URL:  http://{serverName}:{port}/dcma/rest/restartAllBatchInstance

Sample Client Code Utilizing Apache Commons HttpClient

private static void restartAllBatchInstance() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/restartAllBatchInstance";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

restartBatchInstance

This web service restarts a batch from the specified module. The user can only restart batch instances that are accessible to their role. Only batches in the Running, Error, Ready for Review, or Ready for Validation states can be restarted.

Request Method: GET

Web Service URL:  http://{serverName}:{port}/dcma/rest/restartBatchInstance/{batchInstanceIdentifier}/{restartAtModuleName}

Sample Client Code Utilizing Apache Commons HttpClient

private static void restartBatchInstance() {
    HttpClient client = new HttpClient();
    String url = "http://{serverName}:{port}/dcma/rest/restartBatchInstance/BI1/Folder_Import_Module";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

runBatchInstance

This web service takes a batch instance in the Ready for Review or Ready for Validation state and moves it to the next phase in the workflow. The user can only run batch instances that are accessible to their role.

Request Method: GET

Web Service URL:  http://{serverName}:{port}/dcma/rest/runBatchInstance/{batchInstanceIdentifier}

Sample Client Code Utilizing Apache Commons HttpClient

private String runBatchInstance() {
    String webserviceURL = "http://localhost:8080/dcma/rest/runBatchInstance/BI15";
    HttpClient httpClient = new HttpClient();
    GetMethod mget = new GetMethod(webserviceURL);
    String webserviceResponse = "";
    try {
        int statusCode = httpClient.executeMethod(mget);
        System.out.println("Webservice status code: " + statusCode);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mget.getResponseBodyAsString();
            // Generating result as responseBody.

            System.out.println(mget.getResponseBodyAsString());
            webserviceResponse = responseBody;

            mget.releaseConnection();
            return webserviceResponse;
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return webserviceResponse;
}

searchTextForDocFuzzy

This web service searches fuzzy database index data to look for matches with the supplied search text. This web service emulates the document-level Fuzzy DB search field in the Validation screen in the Transact user interface.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/searchTextForDocFuzzy

Sample Client Code Utilizing Apache Commons HttpClient

private static void searchTextForDocFuzzy() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/searchTextForDocFuzzy";
    PostMethod mPost = new PostMethod(url);
    Part[] parts = new Part[4];
    try {
        parts[0] = new StringPart("batchClassIdentifier", "BC1");
        parts[1] = new StringPart("documentType", "Invoice-Table");
        parts[2] = new StringPart("searchText", "*");
        parts[3] = new StringPart("searchType", "0");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

searchTextForFieldFuzzy

This web service searches fuzzy database index data to look for matches with the supplied index field-level text. This web service emulates the field-level Fuzzy DB search field in the Validation screen in the Transact user interface.

Request Method: POST

Web Service URL:  http://{serverName}:{port}/dcma/rest/searchTextForFieldFuzzy

Sample Client Code Utilizing Apache Commons HttpClient

private static void searchTextForDocFuzzy() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/searchTextForDocFuzzy";
    PostMethod mPost = new PostMethod(url);
    Part[] parts = new Part[4];
    try {
        parts[0] = new StringPart("batchClassIdentifier", "BC1");
        parts[1] = new StringPart("documentType", "Invoice-Table");
        parts[2] = new StringPart("searchText", "*");
        parts[3] = new StringPart("searchType", "0");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

setBatchClassField

This web service creates batch class fields in the supplied batch class identifier.

Request Method: POST

Web Service URL:  http://{serverName}:{port}/dcma/rest/setBatchClassField


tableExtractionHOCR

This web service will extract table data from the HOCR.xml file.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/batchClass/tableExtractionHOCR

Sample Client Code Utilizing Apache Commons HttpClient

private static void tableExtractionHOCR() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/batchClass/tableExtractionHOCR";
    PostMethod mPost = new PostMethod(url);
    // adding file for sending
    File file1 = new File("C:\\sample\\sample.xml");
    File file2 = new File("C:\\sample\\US-Invoice_HOCR.xml");
    Part[] parts = new Part[2];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            // Generating result as responseBody.
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

uploadBatch

This web service uploads a batch for a given batch class. The uploaded file is copied to the batch class’s drop folder as a single folder. The user must be authorized to execute a batch instance in that batch class otherwise an error message will be generated.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/uploadBatch]/{batchClassIdentifier}/{batchInstanceName

Sample Client Code Utilizing Apache Commons HttpClient

private static void uploadBatch() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/uploadBatch/{BatchClassIdentifier}/{BatchInstanceName} ";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\sample1.tif");
    Part[] parts = new Part[1];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        MultipartRequestEntity entity =  new  MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        String responseBody = mPost.getResponseBodyAsString();
        // Generating result as responseBody.
        System.out.println(statusCode + "***" + responseBody);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

v2/ocrClassifyExtract

This web service was designed primarily to work with the Nintex workflow engine. It performs OCR, classification and extraction on the supplied input documents. Classification is based only on the first page of each file before extracting the index fields defined in the corresponding batch class. Classification and extraction are performed based on the plugins configured in the corresponding batch class, with two exceptions: 1) The PAGE_PROCESS_SCRIPTING_PLUGIN plugin will not be executed; and 2) Table extraction will be performed if the plugin is turned on, but extracted table data will not be returned in the response.

Only one file can be supplied as input, but multiple files can be processed at one time by combining them in a zip file and submitting the zip file to the web service. However, note that each physical file inside the zip file will be treated as a single logical file, and will be classified based on the contents of the first page only (no separation will occur within the individual files).

This web service supports using a PDF file’s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/v2/ocrClassifyExtract


v2/ocrClassifyExtractBase64

This web service performs the same functionality as the v2/ocrClassifyExtract web service, but it uses a Base64-encoded string as input. Many cloud technologies today (such as Box, Salesforce, and Microsoft Flow) stream data using Base64 encoding. By supporting a Base64-encoded input format, this web service provides greater flexibility to integrate Ephesoft Transact advanced capture capabilities into users’ custom solutions.

The v2/ocrClassifyExtractBase64 web service performs OCR, classification and extraction on the supplied input documents. Classification is based only on the first page of each file before extracting the index fields defined in the corresponding batch class. Classification and extraction are performed based on the plugins configured in the corresponding batch class, with two exceptions: 1) The PAGE_PROCESS_SCRIPTING_PLUGIN plugin will not be executed; and 2) Table extraction will be performed if the plugin is turned on, but extracted table data will not be returned in the response.

Only one file can be supplied as input, but multiple files can be processed at one time by combining them in a zip file and submitting the zip file to the web service. However, note that each physical file inside the zip file will be treated as a single logical file, and will be classified based on the contents of the first page only (no separation will occur within the individual files).

This web service supports using a PDF file’s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method.

The v2/ocrClassifyExtractBase64 web service returns a minimized JSON response.

Here’s an example of a JSON input file for the v2/ocrClassifyExtractBase64 web service:

{
"batchClassIdentifier": "BC6",
"fileName": "Filename.pdf",
"fileContent": "<Base64-Encoded String>"
}

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/v2/ocrClassifyExtractBase64


Image Processing Web Services

convertTiffToPdf

This web service generates PDF files for the input TIFF file. If the input TIFF file is a multi-page file, a multi-page PDF will be generated.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/convertTiffToPdf

Sample Client Code Utilizing Apache Commons HttpClient

private static void convertTiffToPdf() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/convertTiffToPdf";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\sample1.tif");
    File file2 = new File("C:\\sample\\sample2.tif");
    Part[] parts = new Part[5];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        parts[2] = new StringPart("inputParams", "");
        parts[3] = new StringPart("outputParams", "");
        parts[4] = new StringPart("pdfGeneratorEngine", "IMAGE_MAGICK");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            InputStream in = mPost.getResponseBodyAsStream();
            // output file path for saving results.
            String outputFilePath = "C:\\sample\\serverOutput.zip";
            // retrieving the searchable pdf file
            File f = new File(outputFilePath);
            FileOutputStream fos = new FileOutputStream(f);
            try {
                byte[] buf = newbyte[1024];
                int len = in .read(buf);
                while (len > 0) {
                    fos.write(buf, 0, len);
                    len = in .read(buf);
                }
            } finally {
                if (fos != null) {
                    fos.close();
                }
            }
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

createMultiPageFile

This web service will create a multi-page PDF file from one or more single-page TIFF images. A multi-page TIFF file can optionally be created at the same time.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/createMultiPageFile

Sample Client Code Utilizing Apache Commons HttpClient

private static void createMultiPage() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/createMultiPageFile";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\WebServiceParams.xml");
    File file2 = new File("C:\\sample\\sample1.tif");
    File file3 = new File("C:\\sample\\sample2.tif");
    Part[] parts = new Part[3];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        parts[2] = new FilePart(file3.getName(), file3);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            InputStream inputStream = mPost.getResponseBodyAsStream();
            // Retrieving file from result
            File file = new File("C:\\sample\\serverOutput.zip");
            FileOutputStream fos = new FileOutputStream(file);
            try {
                byte[] buf = newbyte[1024];
                int len = inputStream.read(buf);
                while (len > 0) {
                    fos.write(buf, 0, len);
                    len = inputStream.read(buf);
                }
            } finally {
                if (fos != null) {
                    fos.close();
                }
            }
            System.out.println("Web service executed successfully..");
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password..");
        } else {
            System.out.println(statusCode + " *** " + mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing..");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

createMultiPagePDFFromSinglePDFs

This web service creates a multi-page PDF file from a number of single page PDF files.

This web service supports using a PDF file’s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method. If any of the single-page PDF files contain an EText layer, the resulting multi-page PDF file will also contain an EText layer.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/createMultiPagePDFFromSinglePDFs


createSearchablePDF

This web service is used to generate a searchable PDF file.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/createSearchablePDF

Sample Client Code Utilizing Apache Commons HttpClient

private static void createSearchablePDF() {
    HttpClient client = new HttpClient();
    // URL for webservice of create searchable pdf
    String url = "http://localhost:8080/dcma/rest/createSearchablePDF";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\sample1.tif");
    File file2 = new File("C:\\sample\\sample2.tif");
    File file3 = new File("C:\\sample\\sample3.tif");
    File file4 = new File("C:\\sample\\sample4.tif");
    File file5 = new File("C:\\sample\\Fpr.rsp");
    Part[] parts = new Part[9];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        parts[2] = new FilePart(file3.getName(), file3);
        parts[3] = new FilePart(file4.getName(), file4);
        parts[4] = new FilePart(file5.getName(), file5);
        parts[5] = new StringPart("isColorImage", "false");
        parts[6] = new StringPart("isSearchableImage", "true");
        parts[7] = new StringPart("outputPDFFileName", "OutputPDF.pdf");
        parts[8] = new StringPart("projectFile", "Fpr.rsp");
        parts[9] = new StringPart("ocrEngine", "Recostar");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            InputStream inputStream = mPost.getResponseBodyAsStream();
            // output file path for saving result
            String outputFilePath = "C:\\sample\\serverOutput.zip";
            // retrieving the searchable pdf file
            File file = new File(outputFilePath);
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            try {
                byte[] buf = new byte[1024];
                int len = inputStream.read(buf);
                while (len > 0) {
                    fileOutputStream.write(buf, 0, len);
                    len = inputStream.read(buf);
                }
            } finally {
                if (fileOutputStream != null) {
                    fileOutputStream.close();
                }
            }
            System.out.println("Web service executed successfully.");
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

splitMultipageFile

This web service takes an incoming multi-page PDF or TIFF file and splits it apart into single-page TIFF files. ImageMagick is used for splitting multi-page TIFF files, and Ghostscript is used for splitting multi-page PDF files.

Request Method: POST

Web Service URL:  http://{serverName}:{port}/dcma/rest/splitMultipageFile

Sample Client Code Utilizing Apache Commons HttpClient

private static void splitMultiPageFile() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/splitMultipageFile";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\sample.pdf");
    File file2 = new File("C:\\sample\\sample.tif");
    Part[] parts = new Part[5];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        parts[1] = new FilePart(file2.getName(), file2);
        parts[2] = new StringPart("inputParams", "gswin32c.exe -dNOPAUSE -r300 -sDEVICE=tiff12nc -dBATCH");
        parts[3] = new StringPart("isGhostscript", "true");
        parts[4] = new StringPart("outputParams", "");
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            InputStream in = mPost.getResponseBodyAsStream();
            File file = new File("C:\\sample\\serverOutput.zip");
            FileOutputStream fos = new FileOutputStream(file);
            try {
                byte[] buf = newbyte[1024];
                int len = in .read(buf);
                while (len > 0) {
                    fos.write(buf, 0, len);
                    len = in .read(buf);
                }
            } finally {
                if (fos != null) {
                    fos.close();
                }
            }
            System.out.println("Web service executed successfully..");
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password..");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.err.println("File not found for processing..");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}

splitMultiPagePDFToSinglePagePDF

This web service splits a multi-page PDF file into single-page PDF files.

This web service supports using a PDF file’s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method. If any pages of the incoming PDF file contain an EText layer, the single-page PDF files generated from those pages will contain an EText layer.

Request Method: POST

Web Service URL:  http://{serverName}:{port}/dcma/rest/splitMultiPagePDFToSinglePagePDF


Mobile Batch Processing Web Services

executeMobileUpload

This web service takes a PDF file as input and performs classification and extraction based on the rules configured in the batch class. This web service supports using a PDF file’s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method.

Request Method: POST

Web Service URL:  http://{serverName}:{port}/dcma/rest/executeMobileUpload


saveMobileUpload

This web service takes the input PDF files and the batch.xml file returned as the response of a previous web service call (and subsequently modified by the user to correct extracted document-level field values), and copies all of those items to the batch class drop (UNC) folder. This web service was developed for the SnapDoc mobile application, and will be of limited use for direct end users. The PDF files represent the documents classified by the SnapDoc application, and the batch.xml file contains the values of the extracted index fields.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/saveMobileUpload


Reporting Web Services

decryptReportingBatchXml

This web service decrypts the batch.xml file in the report-data folder contained in the SharedFolders area. The web service will find the batch.xml.zip file corresponding to the provided plugin/module name, then decrypt the XML file inside that zip file.

Request Type: GET

Web Service URL: http://{serverName}:{port}/dcma/rest/decryptReportingBatchXml/{batchInstanceIdentifier}/{pluginName}

Sample Client Code Utilizing Apache Commons HttpClient

private static void decryptReportingBatchXml() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/decryptReportingBatchXml/BI2/Folder_Import";
    GetMethod getMethod = new GetMethod(url);
    int statusCode;
    try {
        statusCode = client.executeMethod(getMethod);

        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = getMethod.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(getMethod.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (getMethod != null) {
            getMethod.releaseConnection();
        }
    }
}

runReporting

This web service synchronizes the reporting database.

Request Method: POST

Web Service URL: http://{serverName}:{port}/dcma/rest/runReporting

Sample Client Code Utilizing Apache Commons HttpClient

private static void runReporting() {
    HttpClient client = new HttpClient();
    String url = "http://localhost:8080/dcma/rest/runReporting";
    PostMethod mPost = new PostMethod(url);
    File file1 = new File("C:\\sample\\reporting.xml");
    Part[] parts = new Part[1];
    try {
        parts[0] = new FilePart(file1.getName(), file1);
        MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
        mPost.setRequestEntity(entity);
        int statusCode = client.executeMethod(mPost);
        if (statusCode == 200) {
            System.out.println("Web service executed successfully.");
            String responseBody = mPost.getResponseBodyAsString();
            System.out.println(statusCode + " *** " + responseBody);
        } else if (statusCode == 403) {
            System.out.println("Invalid username/password.");
        } else {
            System.out.println(mPost.getResponseBodyAsString());
        }
    } catch (FileNotFoundException e) {
        System.out.println("File not found for processing.");
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (mPost != null) {
            mPost.releaseConnection();
        }
    }
}