Ephesoft Script Guide

Scripting functionality in Ephesoft is supported where a custom requirement can be handled. Ephesoft includes power to perform custom functionality during different stages of batch processing. This functionality is supported through the scripts present inside batch class folder in Scripts folder. These scripts are Java scripts which access batch.xml through two techniques: DOM Parser and JDOM Parser. All the scripts present should be developed using one of the earlier mentioned parser only.

Batch Instance Group Feature

This feature is used to provide the roles on the batch instance. If user role have an access to batch instance using batch instance group feature than that batch will display on the BatchList screen. User will able to review/validate the same batch instance.

For this feature we are introduced the new database table “batch_instance_groups” for storing the batch instance identifier and user roles. This table stores all the mapped user roles with the batch instances.

Database Structure:

BatchInstanceGroupDb

Method for assigning roles in batch instance group table:

public void assignedBatchInstanceGroup(String batchInstanceIdentifier, String userRole) throws DCMAException

Configurable parameters:

BatchInstanceGroupParams

Example file: ScriptDocumentAssembler_BatchInstanceGroupFeature.java

Force Review Feature

The following is the implementation of the ForceReview feature:

  1. A new tag is added to the batch.xml for any document level field by the name ForceReview. Assumption: This “ForceReview“ tag will come into play only if the document containing it is invalid.
  2. This tag is not mandatory. If it does not exist(or the value of it is not “true”) for a document level field, the functionality will work as earlier.
  3. When this batch opens on the RV Screen, and this tag is found with a value “true” (for an invalid document):
    1. Before the user saves the document once(by pressing CTRL+s/S or CTRL+q/Q) this field will appear RED(irrespective of REGEX validation).
    2. Once the user presses CTRL+s/S or CTRL+q/Q on a certain field, we will make the value of the tag forceReview “False” for that field and the field will now get validated according to the earlier functionality (REGEX validation).

It is expected that it will be the responsibility of the script to handle the setting of the ForceReview tag in sync with the document validity setting.

The ForceReview tag of a field will not make a document invalid. It will only prevent a document level field from getting validated(in a document in an invalid state) if set to true.

This ForceReview tag won’t exist by default(before validation).

Provided is a sample script for the generation of this ForceReview tag(or modifying it if it is already present) with a value “true” for every alternate(note the i+=2 in the script) document level field encountered in a batch.xml.

Example file: Force_Review_Feature_SampleScript.java

ScriptAddNewTable.java

The Add New Table script is useful for being able to generate a predefined table on the fly in the Validation view.

Example Scenario:

If you are processing invoice documents and have defined table extraction during the normal means, it is still possible that if the document is of poor image quality the table you have defined for extraction may not be detected, or may be incomplete. In this case, you can use the Add New Table script to automatically generate a table for your invoice document type with the click of a button. You could create a new empty table of your required structure, or even a populated one… using other extracted values from the documents fields to populate the table values from a database table.

Example file: ScriptAddNewTable.java

ScriptAutomaticValidation.java

The Automatic Validation script is executed in the Ephesoft Batch Class work flow prior to reaching the Validation stage. This is the opportune time to implement any custom logic you may require by running verification against the values that have been extracted for the fields defined.

Example Scenario:

You may wish you to retrieve the extracted value from one field, perhaps a Social Security Number, and use it to perform a look-up operation to an external database, retrieving an associated name. You could then in turn us the results of these SQL query to populate the values of other document level fields defined in Ephesoft.

Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts

Example file: ScriptAutomaticValidation.java

ScriptDocumentAssembler.java

The Document Assembler script is executed in the Ephesoft Batch Class work flow following the Page Processing Module, and Prior to reaching the Document Review stage. At this point the batch .xml has undergone Ephesoft’s classification routines and the batch’s contents are structured into documents, with confidence scores assigned. However, perhaps you have a unique situation where the default Ephesoft classification behavior alone will not organize your batch’s documents as your require. This script is the ideal location to implement any logic to customize the classification organization of your batch. Although Document Level Fields are not yet present in the batch .xml at this point, page level fields are making Script

Example Scenario:

You may be using cover sheets to aid in the classification accuracy for your documents. However by the time the work flow reaches the ScriptDocumentAssembler Ephesoft’s classification routines have already worked their magic and you may no longer have any use for the cover sheets. You can use this script to define some logic to remove the first page of every document, which in this case would be the cover sheets.

We’ve provided as an example resource, a script that does exactly this: ScriptDocumentAssembler_remove-1st-page.java

ScriptExport.java

The Export script is executed in the Ephesoft Batch Class work flow during the processing of the Export Module. At this point all of Ephesoft’s separation, classification, extraction, and validation have been performed and the batch is in the process of leaving the Ephesoft system. Consequently, ScriptExport.java is the ideal place to implement logic facilitating custom export requirements.

Example Scenario #1: As a batch is leaving the Ephesoft system, you may intend to import its .xml and image files into a document repository system. Your targeted system may have its own internal XML schema for describing its contents, and to make the transition a seamless one you want to consider applying an XSLT translation to the Ephesoft batch .xml so that it can be automatically imported and recognized by its destination system without manual effort.

Example Scenario #2: Perhaps you have a specific document management system such as FileBound in mind. FileBound uses Divider and Separator values to index its contents. Ephesoft provides a FileBound Plugin in the Export Module. However, in addition to this you can implement logic in the ScriptExport.java file to populate the batch documents’ divider and separator fields based on a captured extraction value, barcode, or other means. Through Ephesoft scripting you could use an extracted barcode value as a look up key in a SQL query to an external database table to retrieve the appropriate divider and separator values for a given document type.

Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts

Example file: ScriptExport.java

ScriptExtraction.java

The Extraction script, although similar in sequence position to the ScriptAutomaticValidation.java, is useful for the purpose of separating extraction from validation.

Example Scenario:

Assume you have some OMR field extraction defined to extract check boxes denoting credit card type. For example there could three boxes total, signifying a choice of visa, american express, or mastercard. If filled out correctly the form should only have a check mark in one of the boxes. RecoStar OMR extraction will represent these three check boxes as a three character string of binary values, with the box containing a mark being represented by a “1” value (the others, “0”). Your Extraction script function could analyze the binary values to determine which of the three credit card vendors is being represented and set a document level field value to a string value of “visa”, “amex”, or “mastercard”.

Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts

ScriptFieldValueChange.java

The Field Value Change script can be toggled through the Ephesoft Validation Module, and when enabled will fire when the value of a field is changed in the user Validation View. This can be extremely useful if you want to have the changes you make to one field automatically produce a change in value of one or more other fields.

Example Scenario #1:

Consider the case where you have a field that is of the drop down list type. This field contains a list of various departments within an organization (eg: HR, IT, etc). In addition to this field you have another drop down field that serves as a list of users. You can use the Field Change script to implement logic such that change the department value for field #1 will automatically update the drop down list of field #2 with users that correspond to that newly selected department.

Example Scenario #2:

Perhaps you have had a document arrive in Validation View with a loan number field that has been extracted, and some corresponding fields that contain information related to the loan number. However, consider if the loan number is incorrect, and your user manually needs to change it. Instead of having to also manually look up and change all of the corresponding fields, the Field Change Value script could make it so that changing the Loan Number field value automatically performs a look up operation to a database and populates the additional fields with the information on file for that loan number.

Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts

Example file: ScriptFieldValueChange.java

FunctionKey.java

The Function Key script allows for multiple methods to be defined within the FunctionKey.java and have these individual methods bound to keys on the users keyboard to act as keyboard shortcuts for executing pieces of custom functionality.

Example Scenario:

Consider that you may have a default set of values for a given document type that you want the option to populate its fields with in Validation View at the push of a button. In FunctionKey.java you would implement a method to set the fields of that document type to a set of default values. In the Ephesoft Validation Module you can define the Function Key that you want to associate with this method. You must specify both the name of the function as well as the key that you wish you bind it to. Having done so you should now see the Function Key that you specified as an icon in the Validation View. The custom function key method can now be invoked by clicking this button or striking the specified key itself.

Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts

Example file: ScriptFunctionKey.java

ScriptPageProcessing.java

The Page Processing script is useful for conducting operations on the XML representation of a batch’s pages before they have undergone classification and encapsulation into documents.

Example Scenario:

To reduce batch processing time it is possible to use ScriptPageProcessing to remove pages that are ‘garbarge’ and don’t contain valid OCR data. You could implement a function that would iterate through the collection of pages, and from each page element retrieve the corresponding OCR file (.html) and image file name. If the OCR data for the page is nonexistent, and the original image size is below a certain threshold you can deem the page to be junk and remove it from the batch .xml. By removing these useless pages your batch will be able to traverse the rest of the batch class workflow more efficiently and with an improved processing time.

Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts

ScriptValidation.java

The Validation script differs from the Automatic Validation script in that it is run during the user Validation User Interface experience, where as Automatic Validation executes and performs custom validation steps immediately before the batch is presented to the user in the Validation UI. The benefit is this is that as the user is making changes to the document field values in the Valdiation UI, the Validation Script can be triggered to run after each change to ensure that the changes are put through custom validation processing requirements.

Example Scenario:

You may have some a document level field, AccountNum, where the value being extracted should correspond to an existing account number in an external database. Perhaps due to poor image quality, the OCR’d value for the account number is either incomplete or incorrect and so the document appears in Validation with its field highlighted in red. The user is able to see the corresponding image and keys in what they believe to the the account number appearing on the image, but you want to ensure that they haven’t made a mistake and what they are inputting is indeed a valid account number. In this case it is possible to implement a function that takes the value of the AccountNum field and performs a database look up to verify that the value does in fact exist. This check can run each time after the user has modified the AccountNum document field value and attempts to save their changes.

Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts

Ephesoft Plugin Dev

Creating Sample Plugin

In order to create a new plugin, following steps need to be implemented:

Download the plugin code sample Download Now

1. Click on “File -> New -> Other…” option.
Plugin_1
2. Type “maven” and select “Maven project” from the list shown below.
Plugin_2
3. Check the “Create a simple project” option and click “Next”.
Plugin_3
4. Fill in the particulars for “Artifact” i.e. details about new project. These details include

1. “Group Id”: group id for the project as per maven artifacts standards
2. “Artifact Id”: artifact id, i.e. representation name for the plugin for use in various other projects.
3. “Version”: version of the plugin.
4. “Packaging”: type of packaging to be used for the project. In our application we use “jar” packaging.
After entering the above details for the new plugin, click on “Finish”.
Plugin_4
5. The structure shown below will be generated for the current project which includes the following:

1. “src” package: used for the storing the source code and resources used by the plugin.
2. “target” package: used for storing the target files i.e. the <b.“.class”</b> files, “.jar” files of the plugin.
3. “pom.xml” file: contains the information about the plugin.

Now start creating desired package structure for the project by right clicking on the “java” package and selecting the “new→others” option and selecting the “package”.
Plugin_5
6. Type the hierarchical structure of the project and click on “Finish”.
Plugin_6
7. Above operation will create a package structure shown below.
Plugin_7
8. Create the desired files and corresponding folders for the plugin. Sample files can be found in the sample source code as well.
Plugin_8
9. Now that the plugin is ready with all the content, right click on the project name, go to “Run As” option and from the list shown choose “Maven Build”.
Plugin_9
10. A pop up window for editing the “Run/Debug” configuration will open up. In the “Goals” field, type “clean install”, check the “offline” and “Skip Tests” options and then click “Apply”.
Plugin_10
11. For creating the jar file for the plugin following settings need to be taken care of:

1. Goto maven repository. Default path for the same is C:\Documents and Settings\{user-name}\.m2\repository folder.
2. Create the folder structure com\ephesoft\dcma\ephesoft\<VERSION_NUMBER> inside the repository folder.
3. Copy and paste the Ephesoft.jar inside the folder.
4. Rename Ephesoft.jar to Ephesoft-<Version_Number>.jar.
5. In the “pom.xml” file for the plugin make the following entry

<dependencies>

<dependency>

<groupId>com.ephesoft.dcma</groupId>
<artifactId>ephesoft</artifactId>
<version><VERSION_NUMBER></version>
</dependency>
</dependencies>

 

6. Now that we have defined the dependencies for the plugin, we can use the existing code contained within the “ephesoft-<VERSION_NUMBER>.jar” for the desired purpose.
12. Click on “Run”, this will run the maven project and make its “jar”. A .jar file corresponding to the plugin will be created in the target folder for the same.
Plugin_11

Advanced Implementation Steps

1. “Pre Processing” settings: In order to perform some desired work before running a plugin we can create a method in the plugin code file having “@PreProcess” annotation.
2. “Post Processing” settings: In order to perform some desired work after running a plugin we can create a method in the plugin code file having “@PostProcess” annotation.
3. We use the above settings in our application for creating a back up file for batch.xml before and after the plugin has processed which helps us defining the change a plugin has made to the “batch.xml” files for the batch being processed.
4. Sample function for the above scenario:
@PreProcess
public void preProcess(final BatchInstanceID batchInstanceID, String ::pluginWorkflow) }

Assert.notNull(batchInstanceID);
BackUpFileService.backUpBatch(batchInstanceID.getID());
}
@PostProcess
public void postProcess(final BatchInstanceID batchInstanceID, String pluginWorkflow) {

Assert.notNull(batchInstanceID);
BackUpFileService.backUpBatch(batchInstanceID.getID());
}
Use these settings in the new plugin in order to maintain consistency with the current conventions and workflow of the application.
5. BackUpFileService can be used to create backup xml files for the respective plugin.

Workflow Management

Introduction

Establishments:

• A batch class is made of modules, which in turn consist of plugins.
• Dependencies between modules are only a result of the dependencies that exist between plugins.
Inference: By handling the dependencies that exist between plugins, we can create the Validation framework.

• Addition of a new tab in the admin view for workflow management by the name of “Workflow Management” containing the following:

“Plugins List”: List of plugins already present.
“Add New Plugin” button: For adding a new plugin.
“Dependencies” button: On being clicked it will take user to a screen where it can manage the dependencies among the plugins.
“Help” button: On being clicked the user will be shown a pop-up message containing the information about the new plugin upload.
Workflow_1
“Add New plugin”: a plugin upload widget will open up. See the screenshot below
“Browse”: a file selection window will open up.
“Save”: this will save the plugin to the DB after validating the files.
“Cancel”: this will cancel the operation.
This widget will accept a .zip file for uploading.
Contents of the zip file:

.Jar file: The Jar for the plugin to be added.
.Xml file: containing the plugin information.
.Zip file must only contain these two files.
.Zip file and .Jar file must have the same name.
.Jar file content cannot be verified, so please make sure that they are as required.
• In order for this plugin to take effect, user needs to restart the tomcat server.
Note:

• This Zip file after successful validation of its contents will be stored in the location specified in “<DCMA_HOME>\WEB-INF\classes\META-INF\application.properties” file under the property named “plugin_upload_folder_path”.
• The JPDL file for the uploaded plugin will be stored at <Ephesoft-Shared-Folders\workflows\plugins\<PLUGIN_NAME> . This path is configurable in the dcma-batch.properties file.
Workflow_2

XML Structure

<?xml version=”1.0″ encoding=”UTF-8″?><plugin>
<jar-name></jar-name>
<plugin-name></plugin-name>
<plugin-desc></plugin-desc>
<plugin-workflow-name></plugin-workflow-name>
<plugin-service-instance></plugin-service-instance>
<method-name></method-name>
<is-scripting></is-scripting>
<back-up-file-name></back-up-file-name>
<script-name></script-name>
<application-context-path></application-context-path>
<plugin-properties>

<plugin-property>

<name></name>

<type></type>
<description></description>
<is-mandatory></is-mandatory>
<is-multivalue></is-multivalue>
<sample-values>

<sample-value></sample-value>
</sample-values>
</plugin-property>
</plugin-properties>
<dependencies>

<dependency>

<type-of-dependency></type-of-dependency>
<dependency-name></dependency-name>
</dependency>
</dependencies>

</plugin>

Validation on above XML

• All tags are compulsory and will have any string value, except for “is-scripting”,” is-mandatory” and “is-multivalue” tags which will have Boolean values (TRUE, FALSE).
jar-name tag value must match the name of the jar file present in the zip file.
• If “is-scripting” tag has a value “TRUE”, only then the values of “back-up-file-name” and “script-name” tag will be taken into account.
“plugin-property” and “dependency” tag can have multiple instances and have the values for plugin configs and dependencies respectively.

Assumptions

“plugin-service-instance” and “method-name” tags must be correct as they cannot be validated. • “application-context-path” refers to the application context file name for the plugin. • For the dependencies tag:

• For a new plugin, with dependencies as

o ORDER_BEFORE : P2,P3/P4,P5,P6/P7/P8
o UNIQUE : TRUE
o OR (/) operator and AND (,) operator are also supported for specifying complex dependencies.
<dependencies>

<dependency>

<type-of-dependency>ORDER_BEFORE </type-of-dependency>

<dependency-name>IMPORT_BATCH_FOLDER</dependency-name>
</dependency>
<dependency>

<type-of-dependency>ORDER_BEFORE </type-of-dependency>

<dependency-name>IMPORT_MULTIPAGE_FILES/CMIS_PLUGIN</dependency-name>
</dependency>
<dependency>

<type-of-dependency>ORDER_BEFORE </type-of-dependency>

<dependency-name>DOCUMENT_ASSEMBLER_PLUGIN,CLEAN_UP</dependency-name>
</dependency>

</dependencies>

Integrating External Applications with Ephesoft Validation

Ephesoft allows its customers to develop external modules or applications and integrate them to work together with Ephesoft. This section gives in depth details on how to integrate external modules with Ephesoft’s Validation module.

External modules/applications are technology independent and can be written in any language HTML/JavaScript or GWT or JSP/Servelt or combination of both.

Integrated application or module will be displayed in the Review Validation screen as Modal Window. The Right Hand shows the image of the documents where as Left Hand shows the integrated application/module.

Review Validation Screen

BatchDetailScreen

There are shortcut keys as well as buttons defined to fire an External Application for a batch on the Review Validate UI. (App 1, App4, App2, App 3 as can be seen in the above UI)

When the shortcut key or the App button is pressed, the integrated application or module will be displayed in the Review Validation screen as Modal Window.

In the image below, the Right Hand side shows the image of the documents whereas the Left Hand side shows the integrated application/module.

External Application

ExternalApp
IMPORTANT: batch.xml must be updated by the external application. On the click of OK button, Ephesoft simply loads the updated batch.xml.

Follow below steps to for module integration:

1. Let’s assume your application is available at http://localhost:8080/dcma/ExternalApp.html.

2. Login to the Ephesoft Admin Module (Batch Class Management).

3. Navigate to Batch Class -> Modules -> Validate Document module -> Validate Document plugin.

4. Assign URL of the application (http://localhost:8080/dcma/ExternalApp.html) to one of the shortcuts, such as CTRL+8. It is possible to assign multiple applications to multiple shortcuts as you can see below:

External-app-plugin

Closing the external application modal window:

As you can see in the screenshot of the External Application on the review-validate screen, there were two buttons present for closing the external application (earlier).

The OK button provided the functionality of refreshing and displaying refreshed content (on the review-validate screen) for the batch that has been modified through the external application.

The CLOSE button simply goes back to the review-validate screen without refreshing the content of the batch, assuming that no changes have been made to the batch.xml by the external application.

Now we have removed the extra click that the user has to do in case of refreshing the screen or closing the pop updialog window.

Now both the functionalities (i.e. refreshing the screen after batch.xml updates or closing the pop up window without refreshing the Review Validate Screen) will be the implemented via third party applications. We have provided a handle to the externally integrated applications by means of which they can communicate with the Ephesoft Application.

We have removed the ok and close buttons. External applications need to copy the below mentioned method in their code. They need to invoke this method on the respective button (ok or close) calls which they have implemented. External applications will signal Ephesoft to perform respective operations by passing the appropriate operation string in the method argument. Accepted operation strings are listed in the table below.

Method code for GWT based applications:

private native void fireEvent(String operation) /*-{

window.top.postMessage(operation,”*”);

}-*/;

Method code for Javascript based applications:

function fireEvent(var operation) {window.top.postmessage(operation, “*”);}

The action performed by us in accordance to the argument passed to this method in the external application’s code:

Argument Passed by External application Result on our application
“Save” The dialog box containing the external application on the review-validate screen closes and the changes made in batch.xml get reflected on thescreen(The functionality previously provided by the OK button on the dialog box)
“Cancel” The dialog box containing the external application on the review-validate screen closes, without refreshing the RV screen. (The functionality previously provided by the CLOSE button on the dialog box)
Any other string No Change (Dialog box will not disappear)

How to use the External Application:

It is expected that the external application would play around with the data contents of the documents (i.e. the batch) presently being displayed on the review validate screen. (For which the external app is fired)

Hence we provide the external application the following two parameters appended in its URL, using which the external app can fetch/modify/delete the contents of the batch:

  • Path of the batch.xml for the current batch: The batch.xml contains the information regarding the batch. We provide the batch.xml path, which the ::external app can parse and play around with as and when it likes.
The parameter is specified in the URL by: “batch_xml_path”
Encoding of Batch xml path parameter:
The batch xml path is encoded using java.net.URLEncoder and UTF-8 encoding.
  • Document Identifier: The identifier of the document in focus is also passed onto the external application. The parameter is specified in the URL by: “document_id”

Sample URL fired for an external app by Ephesoft:

{Ext. App URL}&document_id={Document Identifier}&batch_xml_path={Path of batch.xml}&ticket={Security Token}

Or

{Ext. App URL}?document_id={Document Identifier}&batch_xml_path={Path of batch.xml}&ticket={Security Token}

External Application and Security:

We are generating a dynamic token for every External Application window which is opened via Ephesoft Application. This token is sent to the External App by appending another parameter “ticket” in the External App URL. Once this token is received by the External App, it can hit the below provided URL for checking the authenticity of the token.

http://{EphesoftServerIP}:{port}/dcma/authenticate?ticket={ticket}

Ephesoft Server in response will send a status code as to whether this ticket is valid or not:

  • Status Code 200 – Authorized
  • 401 – Unauthorized

The token is issued as soon as the user opens the external application window. A valid token becomes invalid once:

  • Token has already been sent to the Ephesoft server for authentication.
  • One hour after this token has been issued.

Configuring the Title of External Applications through the admin UI

We have eliminated the Application URL from the title of External App Window. Title is now configurable through the Admin UI. We have eliminated the Application URL from the title of External App Window. Title is now configurable through the Admin UI.

Netbeans IDE Setup

Ide-setup-1

  • Create a new Java Application Project:

Ide-setup-2

  • To implement and build the Ephesoft scripting classes the Ephesoft.jar file must be added under the project dependencies.

Ide-setup-3

  • Browse to the location of your Ephesoft installation’s library folder and locate Ephesoft.jar. The default path on the server machine is: C:\Ephesoft\Application\WEB-INF\lib

Ide-setup-4

  • As a point of reference for Ephesoft script development you can examine the script files that are packaged with the default batch classes Ephesoft ships with.
    C:\Ephesoft\SharedFolders\BC1\scripts
  • This screenshot depicts and implementation of the ScriptExtraction.java class file. However in this case a main() method has been added to allow for testing & debugging by execution within the class.

Ide-setup-5

  • At this stage the main() method has been implemented to allow for the reading in of an Ephesoft batch .xml file, and passing that Document object to the ScriptExtraction execute() method.
	public static void main(String[] args)
	{
		try {
			SAXBuilder sb = new SAXBuilder();
			Document doc = sb.build("BI10A_batch.xml");
			ScriptExtraction extractor = new ScriptExtraction();
			extractor.execute(doc, null, null);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
  • With the main() method in place it is now possible to execute the ScriptExtraction class. Successful execution is confirmed by the print statements in the NetBeans output section.

Ide-setup-7

Web Services API

Overview

This document gives detailed explanation of web services exposed by Ephesoft application.

Authenticated client calls code sample

Here is the code for making authenticated client calls via Ephesoft Web Services:-

Credentials defaultcreds = new UsernamePasswordCredentials(“username”, “password”);

client.getState().setCredentials(new AuthScope(“serverName”, 8080), defaultcreds);

client.getParams().setAuthenticationPreemptive(true);

List of API’s exposed in Ephesoft Product

Image Processing Web Service

createSearchablePDF

This API will generate the searchable pdf. It takes the input tif/tiff files and rsp file for processing. Input parameters will used to specify the output pdf is searchable or color.

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

Input Parameter
Value
Description
isColorImage
Either “true”/”false” Generates the color pdf if input image is color and value is “true”.
isSearchableImage
Either “true”/”false” Generates the searchable pdf if value is “true”.
outputPDFFileName
String value should ends with .pdf extension Output pdf file name generated using API.
ocrEngine
Engine used for OCRing-Nuance/Recostar Engine used for OCRing.
projectFile
String value should ends with .rsp extension RSP file used as recostar processing.

Checklist:

  1. Input only tiff, tif files for generating searchable pdf.
  2. RSP file is mandatory for generating the searchable pdf in case of Recostar.

Sample Input Used:

ephesoft-web-services\create-searchable-pdf.zip

Sample client code using apache commons http client:-

   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);
   // adding file for sending</nowiki>
   // Adding tif images for processing
   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");
   // Adding rsp file for recostar for processing
   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);
           // adding parameter for color switch
           parts[5] = new StringPart("isColorImage", "false");
           // adding parameter for searchable switch
           parts[6] = new StringPart("isSearchableImage", "true");
           // adding parameter for outputPDFFileName
           parts[7] = new StringPart("outputPDFFileName", "OutputPDF.pdf");
           // adding parameter for projectFile
           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();
                            }
                            }
               }

convertTiffToPdf

This API will generates the pdf for the input tiffs. If 5 input tiffs are provided then 5 pdf will return using this api. This API will have following parameter for configuration.

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

Input Parameter
Value
Description
inputParams
This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php This are the image magick input parameters used for processing the input and output file.
outputParams
This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php This are the image magick output parameters used for optimizing the output file.
pdfGeneratorEngine
Either “IMAGE_MAGICK”/”ITEXT” This will used for pdf generator engine.

Checklist:

  1. Input only tiff, tif files for generating pdf.
  2. If pdfGeneratorEngine is “IMAGE_MAGICK”, than only input params and output params are works.
  3. If Input tiff is multipage tiff than single multipage pdf is generated as output.

Sample Input Used: ephesoft-web-services\convert-tiff-to-pdf.zip

Sample client code using apache commons http client:- privatestaticvoid convertTiffToPdf() {

       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/convertTiffToPdf";
       PostMethod mPost = new PostMethod(url);
       // adding image file for processing.
       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);
           // adding parameter for input params
           parts[2] = new StringPart("inputParams", "");
           // adding parameter for output params
           parts[3] = new StringPart("outputParams", "");
           // adding parameter for pdfGeneratorEngine
           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();
                   }
               }
           } elseif (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 API will break the pdf and multipage tiff into single page tiff. This will used the image magick and ghost script for splitting the input file. This API will have following parameter for configuration.

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

Input Parameter
Value
Description
inputParams
For Image MagicK:

This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php

For Ghost Script:

This value should not be empty. Reference for ghost script input parameter : http://ghostscript.com/doc/8.54/Use.htm#Output_deviceThis parameter will used for both image magick and ghost script.

outputParams
For Image MagicK: This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.phpThis are the image magick output parameters used for optimizing the output file.

isGhostscript
Either “true”/”false”This parameter is used to specified the weather ghost script is using for breaking the pdf/multipage tiff into single page tiff.

 

Checklist:

  1. Input only tiff and pdf file only.
  2. If “isGhostscript” is “true”, than only input params will works and file only break PDF files.
  3. If “isGhostscript” is “false”, than input params and output params will works.

Sample Input Used:

ephesoft-web-services\split-multipage-file.zip

Sample client code using apache commons http client:-

privatestaticvoid 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..");
           } elseif (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 API will create the multipage tif/pdf using “Image MagicK”, “IText” and “GhostScript”. This API works only for tif/tiff files and provided XML file for input parameters. This API will have following parameter for configuration.

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

Input Parameter
Value
Description
imageProcessingAPI
Either “IMAGE_MAGICK” /”GHOSTSCRIPT”/”ITEXT” This parameter is used for generating pdf using image_magick , itext and ghost script.
pdfOptimizationParams
This value should not be empty. Reference for ghost script input parameter : http://ghostscript.com/doc/8.54/Use.htm#Output_device This are the ghost script output parameters used for optimizing the output file.
multipageTifSwitch
Either “ON”/”OFF” This parameter is used for generating multipage tif along with multipage pdf.
pdfOptimizationSwitch
Either “ON”/”OFF” This switch is used for generated optimized pdf.
ghostscriptPdfParameters
This value should not be empty. Reference for ghost script input parameter : http://ghostscript.com/doc/8.54/Use.htm#Output_device This are the ghost script parameter used for creating multipage pdf.

Checklist:

  1. Input only tiff file for processing and xml file for inputs.
  2. If “imageProcessingAPI” is “GHOSTSCRIPT”, than only ghostscriptPdfParameters will works.
  3. If “pdfOptimizationSwitch” is “ON”, than pdfOptimizationParams will works.

Sample Input Used:

ephesoft-web-services\ create-multipage-file.zip

Format for XML:

<WebServiceParams>

 <Params>
   <Param>
     <Name>imageProcessingAPI</Name>
     <Value>GHOSTSCRIPT</Value>
   </Param>
   <Param>
     <Name>pdfOptimizationSwitch</Name>
     <Value>on</Value>
   </Param>
  <Param>
        <Name>pdfOptimizationParams</Name>
        <Value>-q -dNODISPLAY -P- -dSAFER -dDELAYSAFER -- pdfopt.ps</Value>
   </Param>
   <Param>
     <Name>multipageTifSwitch</Name>
     <Value>on</Value>
   </Param>
  <Param>
     <Name>ghostscriptPdfParameters</Name>
     <Value>-dQUIET -dNOPAUSE -r300 -sDEVICE=pdfwrite -dBATCH</Value>
   </Param>
 </Params>

</WebServiceParams>

Sample client code using apache commons http client:-

privatestaticvoid createMultiPage() {
       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/createMultiPageFile";
       PostMethod mPost = new PostMethod(url);
       // Adding XML file for parameters
       File file1 = new File("C:\\sample\\WebServiceParams.xml");
       // Adding tif file for processing
       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..");
           } elseif (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();
           }
       }
   }

Classification Web Service

classifyImage

This API classify the input image as per batch class identifier provided. This API will depend on the three plugin for completion “CREATE_THUMBNAILS_PLUGIN”, “CLASSIFY_IMAGES_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”. If any batch class doesn’t have those plugin than classify image api will not work.

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

Input Parameter
Value
Description
batchClassId
This value should not be empty and it should be batch class identifier as like BC1. This parameter is used for providing batch class identifier on which classify image will perform.

Sample Input Used:

ephesoft-web-services\classify-image.zip

Checklist:

  1. Input file should be single page tif/tiff file only.
  2. batchClassId should be valid batch class identifier and must have the “CREATE_THUMBNAILS_PLUGIN”, “CLASSIFY_IMAGES_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.

Sample client code using apache commons http client:-

privatestaticvoid 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);
           } elseif (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 API will classify the input HOCR as per batch class identifier provided. This API will depend on the following plugins “SEARCH_CLASSIFICATION_PLUGIN”, “DOCUMENT_ASSEMBLER_PLUGIN” and the learning done on the batch class. If any batch class doesn’t have those plugins than classify hocr will not work.

Web Service URL : [ http://{serverName}:{port}/dcma/rest/classifyHOCR]

Input Parameter
Value
Description
batchClassId
This value should not be empty and it should be batch class identifier as like BC1. This parameter is used for providing batch class identifier on which classify HOCR will perform.

Checklist:

  1. Input file should be html file only.
  2. batchClassId should be valid batch class identifier and must have the “SEARCH_CLASSIFICATION_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.

Sample Input Used:

ephesoft-web-services\classify-hocr.zip

Sample client code using apache commons http client:-

privatestaticvoid classifyHocr() {

       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/classifyHocr";
       PostMethod mPost = new PostMethod(url);
       // Adding HTML file for processing
       File file1 = new File("C:\\sample\\US-Invoice.html");
       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);
           } elseif (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 API will classify the input HOCR as per batch class identifier provided. This API will depend on the following plugins “SEARCH_CLASSIFICATION_PLUGIN”, “DOCUMENT_ASSEMBLER_PLUGIN” and the learning done on the batch class. If any batch class doesn’t have those plugins than classify hocr will not work.

Web Service URL : [ http://{serverName}:{port}/dcma/rest/classifyHOCR]

Input Parameter
Value
Description
batchClassId
This value should not be empty and it should be batch class identifier as like BC1. This parameter is used for providing batch class identifier on which classify HOCR will perform.

Checklist:

  1. Input file should be zip file containing HTML’s in it.
  2. batchClassId should be valid batch class identifier and must have the “SEARCH_CLASSIFICATION_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.

Sample client code using apache commons http client:-

privatestaticvoid classifyMultiPageHocr() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/classifyMultiPageHocr“;

PostMethod mPost = new PostMethod(url);

// Adding ZIP file for processing

File file1 = new File(“D:\\sample\\New folder.zip”);

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);

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();

}

}

classifyBarcodeImage

This API is used to classify the input image as per specified batch class. Image file should have barcode and barcode value should be document type which is present in the batch class.

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

Input Parameter
Value
Description
batchClassId
This value should not be empty and it should be batch class identifier as like BC1. This parameter is used for providing batch class identifier on which classify HOCR will perform.

Checklist:

  1. Input file should be tif/tiff file only.
  2. batchClassId should be valid batch class identifier and must have the “BARCODE_READER_PLUGIN” .

Sample client code using apache commons http client:-

privatestaticvoid classifyBarcodeImage(){
       HttpClient client = new HttpClient();
       String url = "http://locahost:8080/dcma/rest/classifyBarcodeImage";
       PostMethod mPost = new PostMethod(url);       
       // Adding image file for processing the barcode classification
       File file1 = new File("C:\\sample\\US-Invoice.tif");
       Part[] parts = new Part[2];
       try {
           parts[0] = new FilePart(file1.getName(), file1);
           // Adding batchClassId for which barcode classification to be perform.
           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);
           } elseif (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();
           }
       }
   }

Extraction Web Service

extractKV

This API will extract the document level fields for the corresponding Key Value pattern provided using input XML. This API will take the HOCR file as input. If the Key Value pattern is not found in the HOCR file than it will create the empty document level fields.

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

Batch Class List >>Recostar Mail Room [BC1] >>Application-Checklist >>Invoice Date >>New KV Extraction

[[image:|511x197px]]

Input Parameter
Value
Description
AdvancedKV
Either “true”/”false” This parameter is used to specifying the KeyValue extraction is perform by advanced key value or not.
LocationType
This value should be one of the following: TOP, RIGHT, LEFT, BOTTOM, TOP_RIGHT, TOP_LEFT, BOTTOM_LEFT,BOTTOM_RIGHT This parameter will fetch the Value pattern of the particular key pattern on the location provided.
NoOfWords
Should be Integer This parameter is used for specify in case of AdvancedKV is false. This parameter is used for adding number word of RIGHT location in the result of the value pattern found in the HOCR.
KeyPattern
This value should not be empty. This value should be valid regex expression. This is used for verify the Key pattern present in given HOCR.
ValuePattern
This value should not be empty. This value should be valid regex expression. This is used for verify the Value pattern present in given HOCR for that particular Key Pattern.
KVFetchValue
This value should be one of the following: ALL, FIRST, LAST This parameter is used to specify the whether we need fetch all, first or last value pattern found.
Multiplier
This value should be float and should be in between 0 to 1 This value is used to multiply with confidence for updating the confidence of the fields extracted using advanced KV.
Length
This value should be integer For getting length value use Ephesoft Admin Screen as display screen shot above
Width
This value should be integer For getting width value use Ephesoft Admin Screen as display screen shot above
Xoffset
This value should be integer For getting xoffset value use Ephesoft Admin Screen as display screen shot above
Yoffset
This value should be integer For getting yoffset value use Ephesoft Admin Screen as display screen shot above
hocrFileName
This value should be string This value should be having HOCR file name passing for processing in XML file format.

CheckList:

  1. For using Advance KV user should have admin access to fetch the accurate value of Length, Width, Xoffset and Yoffset. Before using AdvancedKV, please test the image with Ephesoft Admin Screen and note the values of Length, Width, Xoffset, Yoffset and LocationType for the particular KeyValue pattern.
  2. If AdvancedKV is true than NoOfWords is not use and all other parameters is used.
  3. If AdvancedKV is false than NoOfWords, KeyPattern, ValuePattern and LocationType will work.

Sample Input Used:

ephesoft-web-services\extractkv.zip

Format for XML:

<ExtractKVParams>

   <Params>
       <AdvancedKV>true</AdvancedKV>
       <LocationType>BOTTOM_LEFT</LocationType>
       <NoOfWords>0</NoOfWords>
       <Weight>0</Weight>
       <KeyPattern>APPLICATION</KeyPattern>
       <ValuePattern>[a-zA-Z]{10,15}</ValuePattern>
       <KVFetchValue>ALL</KVFetchValue>
       <Multiplier>1</Multiplier>
       <Length>384</Length>
       <Width>251</Width>
       <Xoffset>284</Xoffset>
       <Yoffset>105</Yoffset>
   </Params>

</ExtractKVParams>

Sample client code using apache commons http client:- privatestaticvoid extractKV() {

       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/extractKV";
       PostMethod mPost = new PostMethod(url);
       // Adding XML for the input.
       File f1 = new File("C:\\sample\\extractKV.xml");
       // Adding HOCR for processing.
       File f2 = new File("C:\\sample\\Application-Checklist.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);
           } elseif (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();
           }
       }
   }

extractFixedForm

Ephesoft Fixed Form Extraction Web Service API[edit]

Overview

This API extracts the value of document level fields present in the given document type from the image provided. The extraction of the pages will be done based on the project processing file mapped to the pages first, second, third and last. For Windows a default page processing file is picked from the default location as defined in the environment variables in case no file is mapped. In case of Linux if no files are mapped against the pages, no extraction is performed.

Input Parameters

Input parameters to the Web Service API would be two files

  • Tiff/PNG (single page or multipage)
  • XML file, with document type and batch class identifier as parameters.

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

Example- http://localhost:8080/dcma/rest/extractFixedForm

Sample for XML

<WebServiceParams>
   <Params>
        <Param>
            <Name>batchClassIdentifier</Name>
            <Value>BCI</Value>
         </Param>
    <Param>
             <Name>docType</Name>
             <Value>Application-CheckList</Value>
          </Param>
    </Params>
</WebServiceParams

CheckList:

  • If colorSwitch is ON then image should be PNG.
  • If colorSwitch is OFF then image should be Tif/Tiff.
  • For Linux Operating System, the color switch is set to OFF, by default.
  • In case the color switch is ON and the uploaded image is a Tiff, it is internally converted into a PNG for processing.

Sample client code using apache commons http client:-

 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();
          }
      }
  }

extractFieldFromHocr[edit]

This API will extract the KV pattern for the given word in the given HOCR.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/extractFieldFromHocr]

Input Parameter
Value
Description
fieldValue

This should not be empty.

This parameter is used for extracting the Key Value pattern for the word provided.

CheckList:

  1. fieldValue is provided for the word on which Key Value pattern would be found.

Sample Input Used:

ephesoft-web-services\extract-field-from-hocr.zip

Sample client code using apache commons http client:-

   private static void extractFieldFromHocr() {
       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/extractFieldFromHocr";
       PostMethod mPost = new PostMethod(url);
       // Adding HTML for extracting field
       File file1 = new File("C:\\sample\\Application-Checklist.html");
       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);
           } elseif (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();
           }
       }
   }

 

extractFieldFromHocr

This API will extract the KV pattern for the given word in the given HOCR.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/extractFieldFromHocr]

Input Parameter
Value
Description
fieldValue
This should not be empty. This parameter is used for extracting the Key Value pattern for the word provided.

CheckList:

  1. fieldValue is provided for the word on which Key Value pattern would be found.

Sample Input Used:

ephesoft-web-services\extract-field-from-hocr.zip

Sample client code using apache commons http client:-

   private static void extractFieldFromHocr() {
       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/extractFieldFromHocr";
       PostMethod mPost = new PostMethod(url);
       // Adding HTML for extracting field
       File file1 = new File("C:\\sample\\Application-Checklist.html");
       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);
           } elseif (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 API will create the document level fields for the document type for the specified batch class for HOCR file passing it.

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

Input Parameter
Value
Description
documentType
This should not be empty and valid document type for that batch class This parameter is used for generating document level fields for defined document type.
batchClassIdentifier
This should not be empty and valid batch class identifier This parameter used for fetching the information of the document for defined document type
hocrFile
This value should not and empty and should have same name as HOCR file attached for processing. This parameter is used for verifying the HOCR file name.

CheckList:-

  1. hocrFile should have same HOCR file name that are passed for processing.
  2. BatchClass having that batchClassIdentifier should have fuzzyDB plugin for processing.
  3. DocumentType should have document level fields for specified document type.

Sample Input Used:

ephesoft-web-services\extract-fuzzy-db.zip

Sample client code using apache commons http client:-

privatestaticvoid extractFuzzyDB() {
       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/extractFuzzyDB";
       PostMethod mPost = new PostMethod(url);
       // Adding HOCR file for processing
       File file = new File("C:\\sample\\Application-Checklist_000.html");
       Part[] parts = new Part[4];
       try {
           parts[0] = new FilePart(file.getName(), file);
           // Adding parameter for docuement type.
           parts[1] = new StringPart("documentType", "Application-Checklist");
           // Adding parameter for batch class.
           parts[2] = new StringPart("batchClassIdentifier", "BC1");
           parts[3] = new StringPart("hocrFile", "Application-Checklist.html");
           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);
           } elseif (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();
           }
       }
   }

barcodeExtraction

This API will create the document level fields for the document type for the specified batch class for barcode in tiff files passing it.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/barcodeExtraction]

Input Parameter
Value
Description
documentType
This should not be empty and valid document type for that batch class This parameter is used for generating document level fields for defined document type.
batchClassIdentifier
This should not be empty and valid batch class identifier This parameter used for fetching the information of the document for defined document type
imageName
This value should not and empty. On this file extraction operation will be performed.

CheckList:-

  1. BatchClass having that batchClassIdentifier should have Barcode Extraction plugin for processing.
  2. DocumentType should have document level fields for specified document type.
  3. Image name should have valid extension i.e. TIF/TIFF.

Sample Input Used:

<WebServiceParams> <Params>

  <Param>
    <Name>batchClassIdentifier</Name>
    <Value>BC1</Value>
  </Param>
  <Param>
    <Name>imageName</Name>
    <Value>US-Invoice.tif</Value>
  </Param>
 <Param>
       <Name>docType</Name>
       <Value>DocTypeName</Value>
  </Param>
  </Params>

</WebServiceParams>

ephesoft-web-services\barcodeExtraction.zip

Sample client code using apache commons http client:-

privatestaticvoid 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());
           } elseif (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();
           }
       }

}

regularRegexExtraction

This API will extract the document level fields for the document type for the specified batch class.

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

Input Parameter
Value
Description
documentType
This should not be empty and valid document type for that batch class This parameter is used for generating document level fields for defined document type.
batchClassIdentifier
This should not be empty and valid batch class identifier This parameter used for fetching the information of the document for defined document type.
hocrFile
This value should not be empty. XML file name for which document level fields will be extracted.

””CheckList:-

  1. This batch class specified should have Regular Regex plugin defined for it.
  2. DocumentType should have document level fields for specified document type.
  3. HOCR file name should have valid extension, i.e., XML.

<WebServiceParams> <Params>

  <Param>
    <Name>batchClassIdentifier</Name>
    <Value>BC4</Value>
  </Param>
 <Param>
       <Name>documentType</Name>
       <Value>Application-Checklist</Value>
  </Param>
  </Params>

</WebServiceParams>

Sample Input Used:

ephesoft-web-services/regularRegexExtraction.zip

Sample client code using apache commons http client:-

privatestaticvoid 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");
       // adding xml file for taking input
       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());
           } elseif (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();
           }
       }
   }

commonAPIForExtraction

This API is required to set the Header in the client for which the extraction to be performed. Rest of the information for the individual api found above.

Input for Extraction Type:

Pass the name of extraction api that is to use in the client header as shown in following example: BARCODE_EXTARCTION, RECOSTAR_EXTARCTION, REGULAR_REGEX_EXTRACTION, KV_EXTRACTION, FUZZY_DB , NUANCE_EXTRACTION

Here’s the sample client code using Regular Regex Extraction:

privatestaticvoid 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 used: 
BARCODE_EXTARCTION
RECOSTAR_EXTARCTION
REGULAR_REGEX_EXTRACTION
KV_EXTRACTION
FUZZY_DB
NUANCE_EXTARCTION*/
           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());
           } elseif (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();
           }
       }
   }

ExtractKVForDocumentType

This Web Service API is used to perform Key Value Extraction for the Document type of the specified Batch Class, on the Basis of HOCR XML provided as an input.

Request Method POST

Web Service URL:

[ http://{serverName}:{port}/dcma/rest/batchClass/ExtractKVForDocumentType]

Input Parameter
Value
Description
BATCH_CLASS_IDENTIFIER This value should be an existing batch class Id. This Parameter specifies the Batch Class Id for key Value extraction needs to be performed.
DOCUMENT_TYPE This should be an existing document type. This tag should contain name of document type of the Batch Class Identifier

for which KV extraction to be performed through Web service API.HOCR_ZIP_FILEHOCR XML/(s) zipped to a folder name should be specifiedZIP file which is uploaded, containing HOCR XML’s on basis

of which extraction is performed. For example HOCR.zip. Please add .zip extension to file name.

Check List:-

  1. Batch_Class_Identifier should be existing and non-empty.
  2. DOCUMENT_TYPE should be existing and non-empty.
  3. HOCR_ZIP_FILE should contain file*_HOCR.xml zipped directly to a folder

Sample Input XML:

<KV_Extraction_DocType>

<Batch_Class>BATCH_CLASS_IDENTIFIER</Batch_Class>    <Document_Type>DOCUMENT_TYPE</Document_Type>

<HOCR_File>HOCR_ZIP_FILE</HOCR_File>

</KV_Extraction_DocType>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for performing key value extraction.

Sample client code using apache commons http client:-

privatestaticvoid performKeyValueExtraction() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/ExtractKVForDocumentType“;

PostMethod mPost = new PostMethod(url);

// Adding Input XML file for processing

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);

} elseif (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();

}

}

}

OCR Web Service

createOCR

This API will generates the OCR result for the specified sample image file. This API works for tif and png file. If processing the color image we accept the png/tif file as input and for black and white image we processing tif file as input.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/createOCR]

Input Parameter
Value
Description
ocrEngine
Either “recostar”/”tesseract/nuance” This parameter is used for configuring the ocrEngine to be used
colorSwitch
Either “ON”/”OFF” This parameter is used
tesseractVersion
Currently we are supporting “tesseract_version_3” This parameter is used for tesseract version to be used.
cmdLanguage
Either “tha”/”eng” This parameter is used for configure the language that has been learnt by tessearact
projectFile
This can be empty in case of tesseract ocrEngine This parameter is validating the RSP used for OCRing in case of recostar

CheckList:-

  1. In case of ocrEngine is recostar, than colorSwitch and projectFile is mandatory parameters.
  2. In case of ocrEngine is tesseract than colorSwitch, tesseractVersion and cmdLanguage is mandatory parameters.
  3. If colorSwitch is ON, input image can be tif/png.
  4. If colorSwitch is OFF than input image should be TIFF.

Sample Input Used:

ephesoft-web-services\create-ocr.zip

File format for XML file:

Sample Input Used:

<WebServiceParams>
<Params>
  <Param>
    <Name>ocrEngine</Name>
    <Value>recostar</Value>
  </Param>
  <Param>
    <Name>colorSwitch</Name>
    <Value>off</Value>
  </Param>
  <Param>
    <Name>tesseractVersion</Name>
    <Value>tesseract_version_3</Value>
  </Param>
   <Param>
    <Name>cmdLanguage</Name>
    <Value>eng</Value>
  </Param>
   <Param>
    <Name>projectFile</Name>
    <Value>Fpr.rsp</Value>
  </Param>
</Params>
</WebServiceParams>

Format for RSP file:

<_Project MajorRevision=”1″ MinorRevision=”0″ Timeout=”180000″>

 <_Collection Name="Libraries">
   <_Library Type="Dll" BaseName="ImageProcess"/>
   <_Library Type="Dll" BaseName="ImageProcess2"/>
   <_Library Type="Dll" BaseName="Recognition"/>
 </_Collection>
 <FullPageOperator Name="Operator" SetupImageFileName="" Country="USA" TextReading="true" ResultCoordinates="OriginalImage" ResultImage="RecoImage" ResultGraphicalObjects="false" DiagnosticsMode="OnError" DiagnosticsFileName="">
   <ImageSequence2Operator Name="ImageProcessing" SetupImageFileName="" RegisterImage="true" DiagnosticsMode="OnError" DiagnosticsFileName="" ConfigurationFileName="" Geometry="-1 0 1683 0 1 2190">
     <LoadImageOperator Name="ImageSourceOperator" FileName="" FileFormat="Unknown" Resolution="200" UnifyResolution="true" RepairResolution="true" AutoRotate="false" IgnorePalette="false" ScaleToGray="0"/>
     <ExtractGrayFromRgbOperator Name="ColorFilterOperator" LumaRed="0.299" LumaGreen="0.587" LumaBlue="0.114"/>
     <BinarizeEdgeAdaptiveOperator Name="BinarizeOperator" EdgeThreshold="80" DoubleResolution="false"/>
     <_Collection Name="BinaryImageSequence">
       <RemoveShadingOperator Name="RemoveShading" MinRegionWidth="10.00" MinRegionHeight="3.00"/>
       <DetectPaperAreaOperator Name="DetectPaperArea" KeepBlackFrame="false" SafetyClass="Medium" DetectTextSkew="true"/>
       <BinaryAutoRotateOperator Name="AutoRotate" DocumentOrientation="Unknown" InputOrientation="MostlyCorrect"/>
       <ProtectBarCodesOperator Name="ProtectBarCodes" SafetyClass="Medium" SearchRegion=""/>
       <RemoveLineSystemOperator Name="RemoveLineSystem" HorizontalLineLength="10.00" VerticalLineLength="12.00" DashedLineLength="30.00" MaxLineWidth="1.50" MaxGapWidth="1.00" BoxSeparatorHeight="4.00" InvertedRegionWidth="12.00" InvertedRegionHeight="4.00" LineQuality="Medium"/>
     </_Collection>
   </ImageSequence2Operator>
   <LayoutOperator Name="LayoutOperator" FindTextBlocks="true"/>
   <FullPageField Name="TextField" Zone="0 0 0 0 0 1" ReaderSelection="Voter" Orientation="Normal" SyntaxMode="Alphanumerical" NumberOfLines="TextLineSegments" MachinetypeHeight="Unknown" MachinetypePitch="Unknown" MachinetypeMinConfidence="100" LogicalContext="On" TrigramMode="On" DictionaryFileName="" DictionaryMode="Incomplete" DictionaryCandidates="Words" CharacterSet="" Pattern="" PassThroughID="None"/>
   <FormGenerator Name="Generator"/>
 </FullPageOperator>

</_Project>

Sample client code using apache commons http client:-

privatestaticvoid createOCR() {

       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/createOCR";
       PostMethod mPost = new PostMethod(url);
       // adding image file for processing
       File file1 = new File("C:\\sample\\sample1.tif");
       // adding xml file for taking input
       File file2 = new File("C:\\sample\\WebServiceParams.xml");
       // adding rsp file used for creating OCR in case of recostar
       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();
                   }
               }
           } elseif (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();
           }
       }
   }

Create_HOCR_XML_for Batch_Class

This Web Service API is used to create HOCR XML of Batch Class of single page tiff/tif passes as an input. This Web Service API requires two Inputs i.e. Input Sample and tif/tiff file to create HOCR_xml.

On the basis of Batch Class Identifier provided as an input,this API will Extract plugin configuration settings of RECOSTAR_HOCR/TESSERACT_HOCR plugin in Page Process module, if property named “Recostar Switch” value is turned ON then process of OCRing will be done from Recostar and its corresponding plugin configurations will be used else Tesseract will be used to perform process of OCRing.

Request Method POST

Web Service URL:

[ http://{serverName}:{port}/dcma/rest/batchClass/createHOCRforBatchClass]

Input parameters required for the batch class creation are as follows:

Input Parameter
Value
Description
batchClassIdentifier
It should contain a value of an existing batch Class Identifier.
The identifier of the Batch Class whose HOCR_XML needs to be created.
imageName
This should be a non-empty Value containing file name with tif/tiff extension.
This parameter value should contain name tif/tiff file for which HOCR XML need to be created with extension specified .For example Application-Checklist.tif

Check list:

  1. Batch Class Identifier should be an existing one.
  2. Only single page tif/tiff should be passed as an input.

Sample Input XML:

<WebServiceParams>

<Params>
  <Param>
     <Name>batchClassIdentifier</Name>
     <Value>BATCH_CLASS_ID</Value>
  </Param>
  <Param>
     <Name>imageName</Name>
     <Value>FILE_NAME</Value>
  </Param>
</Params>

</WebServiceParams>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for creating HOCR XML for Batch Class.

Sample client code using apache commons http client:-

privatestaticvoid createHOCRXML() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/copybatchClass“;

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);

} elseif (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();

}

}

}

Users and Groups Web Service

getBatchInstanceForRole

This API is used to fetch all batch instance list having accessed by the specified role. This API is GET api, works with web url and client code.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/getBatchInstanceForRole/{role}]

Input Parameter
Value
Description
role
This value should not be empty.

This parameter is used for specifying the role name for which batch instance list to be fetched.

Sample client code using apache commons http client:-

privatestaticvoid getBatchInstanceForRole() {

       HttpClient client = new HttpClient();
       // URL path to be hit for getting the batch instance list having accessed by the role specified.
       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);
           } elseif (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();
           }
       }
   }

getBatchClassForRole:

This API is used to fetch all batch class list having accessed by the specified role. This API is GET api, works with web url and client code.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/getBatchClassForRole/{role}]

Input Parameter
Value
Description
role
This value should not be empty.

This parameter is used for specifying the role name for which batch class list to be fetched.

Sample client code using apache commons http client:-

privatestaticvoid 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);
           } elseif (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();
           }
       }
   }

Reporting Web Service

runReporting

This API is used to run reporting on using web services. This web service takes server side installer path as an input and performs synchronizing the report database.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/runReporting]

Input Parameter
Value
Description
installerPath
This value should be valid path. This parameter is used for specifying path fie build.xml for reporting present on the server side.

Checklist :-

  1. This path should be valid file path and must be server path for the build.xml file.

Sample Input Used:

ephesoft-web-services\run-reporting.zip

””Format for inputXML file :

<ReportingOptions>

<installerPath>C:\\testing</installerPath>

</ReportingOptions>

Sample client code using apache commons http client:-

privatestaticvoid 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);
           } elseif (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();
           }
       }
   }

Batch Instance Management Web Service

getBatchInstanceList

This api will return the batch instance list of the batch instance status accessed for the specific role using in the authentication. This API is GET api, works with client code and URL directly.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/BatchInstanceList/{status}]

Input Parameter
Value
Description
status
This values can be NEW, LOCKED,READY,ERROR, FINISHED,ASSIGNED, RUNNING, READY_FOR_REVIEW,

READY_FOR_VALIDATION, RESTARTED, DELETED, TRANSFERRED, RESTART_IN_PROGRESSThis parameter is used for specifying the batch instance status for which batch instance list to be fetched.

Checklist:-

  1. Status should have status provided above in the list.

Sample client code using apache commons http client:-

privatestaticvoid getBatchInstanceList() {

       HttpClient client = new HttpClient();
       // URL path to be hit for getting the batch instance identifier list having status specified.
       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);
           } elseif (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();
           }
       }

}

getAllModulesWorkflowNameByBatchClass

This API will returns the module workflow names and the module names of the specified batch class identifier. This API is GET API, works with client code and web url.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/getAllModulesWorkflowNameByBatchClass/{batchClassIdentifier}]

Input Parameter
Value
Description
batchClassIdentifier
This value should not be empty. This parameter is used for specifying the batch class identifier for which module name to be fetched.

Sample client code using apache commons http client:-

privatestaticvoid 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);
           } elseif (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 API is used to restart the batch instance from specified module. User can restart those batch instances those are accessible by their role. This API is GET api, works with client code and web url.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/restartBatchInstance/{batchInstanceIdentifier}/{restartAtModuleName}]

Input Parameter
Value
Description
batchInstanceIdentifier
This value should be valid batch instance identifier. This parameter is used to specifying the batch instance identifier for which batch instance to be restart.
restartAtModuleName
This value should not be empty. This parameter is used specifying the module name from where batch to be restart.

Checklist:-

  1. Batch Instance identifier should be valid identifier and having access by the user which are authenticate the web service.
  2. restartAtModuleName this value should valid module name and it can be differ with batch class.

””Sample client code using apache commons http client:-

privatestaticvoid restartBatchInstance() {

       HttpClient client = new HttpClient();
       // URL path to be hit for restarting batch instance identifier from specified module.
       // User can restart only those batch instance having status "ERROR", "READY_FOR_REVIEW", "READY_FOR_VALIDATION", "RUNNING"
       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);
           } elseif (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 API is used to delete the batch instance for specified batch instance identifier. This API will delete that batch instance having accessed by the authenticated user.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/deleteBatchInstance/{identifier}]

Input Parameter
Value
Description
batchInstanceIdentifier
This value should be valid batch instance identifier. This parameter is used to specifying the batch instance identifier to be deleted.

Sample client code using apache commons http client:- privatestaticvoid deleteBatchInstance() {

       HttpClient client = new HttpClient();
       // URL path to be hit for deleting the batch instance having access to the authenticated user.
       // User can delete only those batch instance having status "ERROR", "READY_FOR_REVIEW", "READY_FOR_VALIDATION", "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);
           } elseif (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();
           }
       }
   }

restartAllBatchInstance

This API is used to restart all the batch instance having status READY_FOR_REVIEW and READY_FOR_VALIDATION and having access by the authenticated user. This API is GET API, works with clinet code and web url. RestartAll switch should be set to “TRUE” in properties file.

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

Checklist:-

  1. Only those batch will restart having status READY_FOR_REVIEW and READY_FOR_VALIDATION which are accessible by authenticated user.

Sample client code using apache commons http client:- privatestaticvoid restartAllBatchInstance() {

       HttpClient client = new HttpClient();
       // URL path to be hit for restarting the batch instance having access to the authenticated user.
       // User can restart only those batch instance having status "READY_FOR_REVIEW", "READY_FOR_VALIDATION"
       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);
           } elseif (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();
           }
       }
   }

addUserRolesToBatchInstance

This API is used to adding roles to batch instance identifier. This API takes batch instance identifier and role name as an input and adding it to the database. This API is GET api, works with client code and web browser both.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/AddUserRolesToBatchInstance/{batchInstanceIdentifier}/{userRole}]

Input Parameter
Value
Description
batchInstanceIdentifier
This value should be valid batch instance identifier. This parameter is used to specifying the batch instance identifier for which roles to be added.
userRole
This value should not be empty. This parameter is used specifying the role to be added on the specified batch instance identifier.

Sample client code using apache commons http client:- privatestaticvoid 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);
           } elseif (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();
           }
       }
   }

Run Batch Instance

This API is used to run the batch instance from READY_FOR_REVIEW or READY_FOR_VALIDATION module to next phase in workflow. User can restart those batch instances those are accessible by their role. Request Method: GET Web Service URL: [ http://{serverName}:{port}/dcma/rest/runBatchInstance/{batchInstanceIdentifier]} Input Parameters for the Web Service are as follows:

Input Parameter
Value
Description
batchInstanceIdentifier It should contain a value of an existing batch instance Identifier. The parameter value should contain of the Batch Class whose document type is copied.

Note: Value highlighted curly braces in input URL should be replaces with corresponding values.Module name should end with _module. Sample client code using apache commons http client:- privatestaticvoid runBatchInstance() { HttpClient client = new HttpClient(); String url = “http://localhost:8080/dcma/rest/runBatchInstance/BI15” 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 = 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); } elseif (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(); } } }

Batch Class Management Web Service

importBatchClass

This API is used for importing batch class to the ephesoft. This API takes XML for input parameters and exported batch class data as an input. Exported batch class is in zip format as exported by Ephesoft.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/importBatchClass]

Input Parameter
Value
Description
RolesImported
Either “true”/”false” This value is used for importing roles with batch class or not.
EmailAccounts
Either “true”/”false” This value is used for importing email accounts with batch class or not.
UseSource
Either “true”/”false” This value is used for saving the information of source batch class to be imported
cmisPluginProperties
Either “true”/”false” This value is used for importing cmisPluginProperties with batch class or not.
Name
This value should not be empty This value is used to configure the batch class name of the imported batch class.
Description
This value should not be empty This value is used to configure the description of the imported batch class.
Priority
This value should lie in between 1 to 100. This value indicates the priority of batch class.
UseExisting
Either “true”/”false” This value is used for overwrite the existing batch class with new batch class.
UncFolder
This value should not be empty and have any string value that specified directory path These values specify the UNC folder path for batch class to be imported along with batch class.
Script
This tag is configured for ScriptFile to be imported This tag is configured for which Script file to be imported
Folder
This tag is configured for Folder to be imported This tag is configured for which folder to be imported along with batch class

Checklist:-

  1. If UseExisting is “true”, existing batch class will be overwriting with the Folders and Script as well as others parameter.
  2. If UseExisting is “false”, new batch class will created and Folders and Scripts will be used as false.
  3. If UseSource is “true”, new batch class will have same Name, Description and Priority as source batch class.
  4. If UseSource is “false”, new batch class will have property like Name, Description and Priority configured.

SampleInputXML:

<ImportBatchClassOptions>

   <RolesImported>false</RolesImported>
   <EmailAccounts>true</EmailAccounts>
   <UseSource>false</UseSource>
   <Name>BatchClassName</Name>
   <Description>Description</Description>
   <cmisPluginProperties>cmisPluginProperties</cmisPluginProperties>
   <Priority>10</Priority>
   <UseExisting>true</UseExisting>
   <UncFolder>C:\ephesoft-data\Test-UNC</UncFolder>
   <BatchClassDefinition>
       <Scripts>
           <Script>
               <FileName>ScriptDocumentAssembler.java</FileName>
               <Selected>true</Selected>
           </Script>
           <Script>
               <FileName>ScriptPageProcessing.java</FileName>
               <Selected>true</Selected>
           </Script>
       </Scripts>       
       <Folders>
           <Folder>
               <FileName>image-classification-sample</FileName>
               <Selected>false</Selected>
           </Folder>            
       </Folders>
       <BatchClassModules>
           <BatchClassModule>
               <ModuleName></ModuleName>
               <PluginConfiguration>true</PluginConfiguration>
           </BatchClassModule>
       </BatchClassModules>
   </BatchClassDefinition>

</ImportBatchClassOptions>

””Sample client code using apache commons http client:-

privatestaticvoid 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");
           } elseif (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();
           }
       }
   }

exportBatchClass

This API is used for exporting existing batch class. This method will take the batch class identifier and learnt-sample to be exported with the batch class.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/exportBatchClass]

Input Parameter
Value
Description
identifier
This value should not be empty and valid batch class identifier. This parameter is used for identifying which batch class is to be exported.
lucene-search-classification-sample
Either “true”/”false” This parameter is used to configure the lucene learnt sample is exported with batch class or not.
image-classification-sample
Either “true”/”false” This parameter is used to configure the image classification sample is exported with batch class or not.

CheckList:-

  1. Identifier should be batch class identifier.

Sample client code using apache commons http client:- privatestaticvoid 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();
                   }
               }
           } elseif (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();
           }
       }
              }

getBatchClassList

This API returns all the batch class having accessible by the authenticated user. This API is GET API, works with the client code and web url.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/getBatchClassList]

Sample client code using apache commons http client:-

privatestaticvoid 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);
           } elseif (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 API is used to get the roles of the specified batch class. This API is GET API, works with the client code and web url.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/getRoles/{batchClassIdentifier}]

Input Parameter
Value
Description
identifier
This value should not be empty and valid batch class identifier. This parameter is used for identifying which batch class roles to be fetched.

CheckList:-

  1. Identifier should be batch class identifier.

Sample client code using apache commons http client:-

privatestaticvoid 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);
           } elseif (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();
           }
       }

}

Uploading a Batch through a Web Service

uploadBatch

This API is for uploading a new batch to a watch folder for a given batch class. It executes the new batch with supplied tif, tiff or pdf files. User need to be authorized to execute a batch for a particular batch class otherwise an error message would be generated. All the files would be copied to the unc folder of the requested batch class with the folder name supplied by the user as input.

Web Service URL :

[ http://{serverName}:{port}/dcma/rest/uploadBatch]/{batchClassIdentifier}/{batchInstanceName

Input Parameter
Description
batchClassIdentifier
The identifier of the batch class in which user wishes to upload its batch.
batchInstanceName
This name with which user wishes to upload the batch.

CheckList:-

  1. The value for batchClassIdentifier is compulsory and should be valid with permissions to the user to run the batch on it.
  2. The value for batchInstanceName is compulsory and if left empty then it will send an error.

Sample client code using apache commons http client:- privatestaticvoid uploadBatch () {

       HttpClient client = new HttpClient();
       String url = "http://localhost:8080/dcma/rest/uploadBatch/{BatchClassIdentifier}/{BatchInstanceName} ";
       PostMethod mPost = new PostMethod(url); 
   // adding image file for processing
   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.");
           } elseif (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();
           }
       }

}

Batch Class Web service

CopyBatchClass

This API will create the copy of an existing batch class whose identifier is provided as input/source. Other parameters required for the batch class creation are as follows: Request Method POST

Web Service URL:

[ http://{serverName}:{port}/dcma/rest/batchClass/copyBatchClass]

Input Parameter
Value
Description
batchClassName The Name of batch class should not be empty or contains characters like space(“ “) or hyphen(“-“) and should not be more than 255 characters. The unique character is used for naming the new copied batch class.
batchClassDescription This should be a non-empty Value This parameter is the description of the new copied batch class.
batchClassPriority The batch class priority cannot be null or empty and should be between 1 and 100 inclusive of both. The priority of the batch class.
batchUNCFolder The UNC folder name for the batch class. This UNC folder name for the new copied batch class.
copyBatchClassIdentifier This value should be non-empty and a preexisting Batch Class Idenitifer The identifier of the Batch Class which is used as reference for copying.
gridWorkflow Can be true or false States the workflow, is the batch class deployed as grid workflow or normal workflow.

Sample Input XML :

<?xml version="1.0" encoding="UTF-8"?> <WebServiceParams>
 <Params>
   <Param>
     <Name>batchClassName</Name>
     <Value>NEW_BATCH_CLASS_NAME</Value>
   </Param>
   <Param>
     <Name>batchClassDescription</Name>
     <Value>NEW_BATCH_CLASS_DESCIPTION</Value>
   </Param>
   <Param>
     <Name>batchClassPriority</Name>
     <Value>NEW_BATCH_CLASS_PRIORITY</Value>
   </Param>
    <Param>
     <Name>batchUNCFolder</Name>
     <Value>NEW_BATCH_CLASS_UNC_FOLDER_NAME</Value>
   </Param>
      <Param>
     <Name> copyBatchClassIdentifier </Name>
     <Value>EXISTING_BATCH_CLASS_ID</Value>
   </Param>
 </Params>
</WebServiceParams>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for copying an existing batch Class.

Sample client code using apache commons http client:- privatestaticvoid createDocumentType() { 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] = new FilePart(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); } elseif (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(); } } }

Learn File

This API will learn all the files present in the batch class folders for the batch class whose identifier is provided as input. Request Method POST Web Service URL: [ http://{serverName}:{port}/dcma/rest/batchClass/learnFile/{BatchClassIdentifier}]

Input Parameter
Value
Description
BatchClassIdentifier This value should be nonempty and a pre-existing Batch Class’s identifier. The value is provided in the URL only. The identifier of the batch class for which learning has to be done.

Note: – Replace the parameter BatchClassIdentifier in the input URL for which learning should be performed.

Sample client code using apache commons http client:-

privatestaticvoid 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); } elseif (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(); } }

}

Document Type Creator

This API will create the new document type for the specified batch class supplied as an input. Request Method POST

Web Service URL:

[ http://{serverName}:{port}/dcma/rest/batchClass/documentTypeCreator]

Input Parameter
Value
Description
documentTypeName The document type name should be nonempty and should not contain ‘*’ symbol. This parameter is the unique name of the new document type to be create
documentTypeDescription This should be a non-empty Value This parameter is the description of the new document type created
minConfidenceThreshold The minimum confidence threshold cannot be null and should be between 0 and 100 inclusive of both. The minimum threshold value for the documents recognition
formProcessingProjectFile The name of the RSP/ZON file for recostar/nuance extraction This file would be used for KV extraction by Recostar/Nuance engine
batchClassIdentifier This value should be nonempty and a pre-existing Batch Class Identifier The identity of the Batch Class Identifier under which document type is to be created
Hidden Can be true or false This parameter signifies whether new document type created should be hidden or not.

Check List:-

  1. documentTypeName should be unique and non-empty.
  2. minConfidenceThreshold should be a value between 0 and 100.
  3. formProcessingProjectFile should be a name of pre-existing RSP file.
  4. batchClassIdentifier should be an identity of pre-existing Batch Class.

Sample Input XML: <?xml version=“1.0” encoding=“UTF-8”?> <WebServiceParams>

 <Params>
   <Param>
     <Name>documentTypeName</Name>
     <Value>NEW_DOCUMENT_TYPE_NAME</Value>
   </Param>
   <Param>
     <Name>documentTypeDescription</Name>
     <Value>NEW_DOCUMENT_TYPE_DESCRIPTION</Value>
   </Param>
   <Param>
     <Name>minConfidenceThreshold</Name>
     <Value>CONFIDENCE_THRESHOLD</Value>
   </Param>
    <Param>
     <Name>firstPageProjectFile</Name>
     <Value>RSP_FILE_NAME</Value>
   </Param>
    <Param>
     <Name>firstPageProjectFile</Name>
     <Value>RSP_FILE_NAME</Value>
   </Param>
      <Param>
     <Name>batchClassIdentifier</Name>
     <Value>BATCH_CLASS_ID</Value>
   </Param>
      <Param>
     <Name>hidden</Name>
     <Value>TRUE/FALSE</Value>
   </Param>
 </Params>

</WebServiceParams>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for copying an existing batch Class.

Sample client code using apache commons http client:- privatestaticvoid 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] = new FilePart(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); } elseif (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(); } } }Document Type Creator

Upload files for learning files

This API will upload learning files for a particular batch class to Shared Folder\ [BatchClassID]\lucene-search-classification-sample folder [Document-Type] _First_Page

     [Document-Type] _Middle_Page
    [Document-Type] _Last_Page

Or image-classification-sample folder [Application-Installed-Path]\Shared Folder\ [BatchClassID]\image-classification-sample folder [Document-Type] _First_Page

     [Document-Type] _Middle_Page
    [Document-Type] _Last_Page

Or, both depending upon input supplied.

This Web Service API can upload files (tif, tiff or zip file containing tif/tiff files) for multiple document type of a batch class. Only files will be uploaded without performing any operation.

The upload instruction will be in the form of specific xml format.

””Request Method POST

Web Service URL:

[ http://{serverName}:{port}/dcma/rest/batchClass/uploadLearningFile]

Input Parameter
Value
Description
batch_class_id This value should be an existing batch class Id. This Parameter specifies the Batch Class Id for which learning files need to be uploaded.
doc_type_name This should be an existing document type. This parameter specifies the document for which files are getting uploaded. In a single XML file can have multiple doc type name, as we can upload document for more than one doc type at a time.
learning_type Its value can be ‘’lucene’’, ‘’Image’’ or ‘’both’’.
If learning type is selected as Lucene file will be uploaded under  Lucene-search-classification-sample folder  only, if learning type is image than file will be uploaded under image-classification-sample folder only. For learning_type value as ‘Both’, files will be uploaded under Lucene as well as Image folder.
file_name Valid FileName. File can be either of tif, tiff extension or zip extension. In case of zip file the files compressed must be of extension tif, tiff. This API accepts learning files in the form of tif, tiff files or an archive of tif, tiff files. To upload multiple files to a directory user can either use multiple file_name tag or create an archive of all files and upload that archive (.zip file). The structure ofr archive is fixed. It needs to be upload.zip > upload > {file1, file 2, file 3}.

””Other than above parameters specified in xml files, user need to upload a complete and accurate XML with other learning files(tif, tiff, zip files).

Sample XML file format:

<upload_learning_files> <batch_class_id>BATCH_CLASS_ID</batch_class_id>

   <doc_type>            
       <doc_type_name>DOCUMENT_TYPE_NAME_1</doc_type_name>
        <learning_type>LEARNING_TYPE</learning_type>
<page_type_first>
           <files_to_be_uploaded>
               <file_name>FILE_NAME_1</file_name>
               <file_name> FILE_NAME_2</file_name>
           </files_to_be_uploaded>
         </page_type_first>
         <page_type_middle>
           <files_to_be_uploaded>
               <file_name>FILE_NAME_1</file_name>
               <file_name> FILE_NAME_2</file_name>
           </files_to_be_uploaded>
       </page_type_middle>
       <page_type_last>
           <files_to_be_uploaded>
               <file_name>FILE_NAME_1</file_name>
               <file_name> FILE_NAME_2</file_name>
           </files_to_be_uploaded>
       </page_type_last>

</doc_type>

   <doc_type>            
   </doc_type>        

</upload_learning_files>

Note:

  • Values highlighted in blue should be replaced with corresponding values while executing the Web service for uploading Files for learning.
  • Parameters page_type_first, page_type_middle, page_type_last are not mandatory.

Check List:-

Before uploading following points need to ensured first:

  1. XML and other required learning files are attached with the request.
  2. Name of learning files mentioned in the XML must match with the file name uploaded with the request.
  3. XMl format must be same as it shown in Sample XML format. Don’t rearrange the xml elements.
  4. batch_class_id, doc_type_name, learning_type, are mandatory information and must need to be specified. User cannot omit these fields.
  5. If user don’t upload file for particular page type(first, middle and last). He can omit the whole block. (Starting from page_type_first, page_type_middle or page_type_last ).
  6. All the upload information need to be uploaded in single XML file. User cannot split information across different XML and then upload all of them. Only 1 xml will be allowed at a time.
  7. In a xml file there needs to be single batch_class_id, but there can be multiple <doc_type>. Inside a doc_type there can only one doc_type_name, learning_type , page_type_first, page_type_middle, page_type_last block.
  8. If learning files for a particular page folder(ex. First page) are getting uploaded in a single file zip. Zip folder need to follow a specific structure. {zipfileName.zip} > {zipFileName folder} >{file1, file 2, file3 and so on}. Zip file name and first folder name inside zip file needs to be same.

Sample client code using apache commons http client:- privatestaticvoid learnFile() { HttpClient client = new HttpClient(); 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 serverint 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); } elseif (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(); } } }

CopyDocumentType

This Web Service API is used to copy an Existing document type for a batch class to create new document type. It takes an XML as input containing information like Existing Document type Name, New Document type name its Description and confidence threshold and output of this API is new document type in line with existing document type.

Request Method: POST

Web Service URL:

[ http://{serverName}:{port}/dcma/rest/batchClass/copyDocumentType]

Input Parameters for the Web Service a as follows:

Input Parameter
Value
Description
BATCH_CLASS_ID It should contain a value of an existing batch Class Identifier. The identifier of the Batch Class whose document type is copied.
EXISTING_DOC_TYPE_NAME This should be a non-empty Value containing existing document type name. This parameter should contain name of document type of the Batch Class Identifier

which is to be copied through Web service API.NEW_DOC_TYPE_NAMEThis value should be unique name for new document type created.This parameter should unique name for new document type which is to be created.NEW_DOC_TYPE_DESCRIPTIONThis value should contain description for new document type created.This parameter should description for new document type which is to be created.CONFIDENCE_THRESHOLDValue should be between 0.0 to 100.0 inclusive of both values.This parameter should contain confidence threshold value, between 0 to 100 for new document type.

””Sample Input XML :

<Copy_Document_Type>

    <Batch_Class_Id>BATCH_CLASS_ID</Batch_Class_Id> 
    <Existing_Doc_Type_Name>EXISTING_DOC_TYPE_NAME</Existing_Doc_Type_Name>
    <New_Document_Type>
         <Name>NEW_DOC_TYPE_NAME</Name>
         <Description>NEW_DOC_TYPE_DESCRIPTION</Description>
       <Confidence_Threshold>CONFIDENCE_THRESHOLD</Confidence_Threshold>
    </New_Document_Type>

</Copy_Document_Type>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for copying an existing document type for a batch Class.

Sample client code using apache commons http client:- privatestaticvoid 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 = 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); } elseif (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(); } } }

Web Services Added/Updated with Ephesoft v4.0.6.1

/advBarcodeExtraction

This web service performs barcode extraction on the input document PDF or a ZIP file (enclosed single page or multipage tiff/tif or pdf). Advanced Barcode Extraction plugin is fetched from the batch class corresponding to the input batch class identifier. The extraction is performed based on configurations of the extraction plugins and rules configured for the particular batch class.

Web Service URL

http://<HOSTNAME>:8080/dcma/rest/advBarcodeExtraction

Example-localhost:8080/dcma/rest/advBarcodeExtraction

Input Parameters

Input parameters to this Web Service API are:

  • PDF File: (single or multipage)/TIFF File (single or multipage)/ ZIP File (zip file may contain single page or multipage tif/tiff or pdf)
  • Batch Class Identifier: String parameter for batch class identifier
  • Document Type Name (optional parameter): if user enters a document type name, then no document classification is performed otherwise classification of the document is performed

Output Parameters:

Batch XML is the output for this web service.

Checklist

  • Extraction is done only if Extraction module is configured for the particular batch class.
  • Extraction is performed only if the advanced barcode extraction plugin is present in particular batch class, with its switch ON.

Sample Code

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();

                                                }

                                }

                }

/extractFieldsForFuzzyDB

This web service extracts index fields as per the batch class configuration for Fuzzy DB. This takes into account both document level and field Fuzzy configuration.

Web Service URL

http://<HOSTNAME>:8080/dcma/rest/extractFieldsForFuzzyDB

Example-localhost:8080/dcma/rest/extractFieldsForFuzzyDB

Input Parameters

Input parameters to this Web Service API are:

  • Batch Class Identifier (Mandatory)
  • Document Type Name (Mandatory)
  • List of HOCR Page(s) (Optional)
  • List of Index Field Name
  • Index Field Value

Sample Code

private static void extractFieldsForFuzzyDB() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/extractFieldsForFuzzyDB“;

PostMethod mPost = new PostMethod(url);

// adding file for sending

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();

}

}

}

/searchTextForDocFuzzy

This web service searches the input text passed as a parameter for Document Fuzzy.

Web Service URL

http://<HOSTNAME>:8080/dcma/rest/searchTextForDocFuzzy

Example-localhost:8080/dcma/rest/searchTextForDocFuzzy

Input Parameters

Input parameters to this Web Service API are:

  • Batch Class Identifier
  • Document Type Name
  • Search Text

Sample Code

private static void searchTextForDocFuzzy() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/searchTextForDocFuzzy“;

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(“documentTye”, “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 the input text passed as a parameter for Field Fuzzy.

Web Service URL

http://<HOSTNAME>:8080/dcma/rest/searchTextForFieldFuzzy

Example-localhost:8080/dcma/rest/searchTextForFieldFuzzy

Input Parameters

Input parameters to this Web Service API are:

  • Batch Class Identifier
  • Document Type Name
  • Index Field Name
  • Search Text

Sample Code

private static void searchTextForFieldFuzzy() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/searchTextForFieldFuzzy“;

PostMethod mPost = new PostMethod(url);

// adding file for sending

Part[] parts = new Part[5];

try {

parts[0] = new StringPart(“batchClassIdentifier”, “BC1”);

parts[1] = new StringPart(“documentTye”, “Invoice-Table”);

parts[2] = new StringPart(“searchText”, “*”);

parts[3] = new StringPart(“searchType”, “0”);

parts[4] = new StringPart(“fieldName”, “State”);

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();

}

}

}

/learnFuzzyDatabase

This web service is used for fuzzy database learning based on the input parameters.

Request Method

POST

Web Service URL

http://<HOSTNAME>:8080/dcma/rest/ batchClass/learnFuzzyDatabase

Example-localhost:8080/dcma/rest/learnFuzzyDatabase

Input Parameters

Input Parameter Value Description
batchClassIdentifier It is a mandatory parameter. A valid batch class identifier. For example: BC4. This parameter defines the batch class for which fuzzy database is to be learned.
documentType This parameter is optional. A valid document type for the selected batch class.

For example: doc1.

This parameter defines that learning is done for the input document type in the selected batch class.
groupNames This parameter is optional. It can have single, multiple group names separated by semi-column, or all groups. A valid group name for the selected batch class.

For example: group1;group2.

For all groups: ALL

This parameter defines that learning is done for the input groups in the selected batch class.

 

Checklist

  • Batch Class having that batchClassIdentifier should have Fuzzy DB plugin configured for processing.
  • Document Type should have document level fields for the specified document type.
  • Group should have proper field level mappings.

Case 1: Input – Batch Class Identifier

In case only batchClassIdentifier is passed as input parameter in the API, learning is done for all the document types within the batch class.

Case 2: Input – Batch Class Identifier and Document Type

In case batchClassIdentifier and documentType is passed as input parameters in the API, Document Fuzzy learning is done for the input document type.

Case 3: Input – Batch Class Identifier, Document Type and Group Name

In case all three parameters are passed in the API, Field Fuzzy learning is done for all the input groups within the document type passed.

  • If multiple groups are required to be passed, then use semi-column separated values (group1;group2).
  • If learning is to be done for all the groups, then pass the value ALL.

Sample Code

private static void learnFuzzyDatabase() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/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(“documentTye”, “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();

}

}

}

Was this article helpful to you?

wikiadmin