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:
- Input only tiff, tif files for generating searchable pdf.
- 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
Checklist:
- Input only tiff, tif files for generating pdf.
- If pdfGeneratorEngine is “IMAGE_MAGICK”, than only input params and output params are works.
- 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.
outputParamsFor 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.
isGhostscriptEither “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:
- Input only tiff and pdf file only.
- If “isGhostscript” is “true”, than only input params will works and file only break PDF files.
- 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:
- Input only tiff file for processing and xml file for inputs.
- If “imageProcessingAPI” is “GHOSTSCRIPT”, than only ghostscriptPdfParameters will works.
- 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:
- Input file should be single page tif/tiff file only.
- 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:
- Input file should be html file only.
- 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:
- Input file should be zip file containing HTML’s in it.
- 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:
- Input file should be tif/tiff file only.
- 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();
}
}
}
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:
- 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.
- If AdvancedKV is true than NoOfWords is not use and all other parameters is used.
- If AdvancedKV is false than NoOfWords, KeyPattern, ValuePattern and LocationType will work.
Sample Input Used:
ephesoft-web-services\extract–kv.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();
}
}
}
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();
}
}
}
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:
- 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();
}
}
}
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:
- 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();
}
}
}
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:-
- hocrFile should have same HOCR file name that are passed for processing.
- BatchClass having that batchClassIdentifier should have fuzzyDB plugin for processing.
- 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();
}
}
}
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:-
- BatchClass having that batchClassIdentifier should have Barcode Extraction plugin for processing.
- DocumentType should have document level fields for specified document type.
- 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();
}
}
}
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:-
- This batch class specified should have Regular Regex plugin defined for it.
- DocumentType should have document level fields for specified document type.
- 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();
}
}
}
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();
}
}
}
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:-
- Batch_Class_Identifier should be existing and non-empty.
- DOCUMENT_TYPE should be existing and non-empty.
- 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:-
- In case of ocrEngine is recostar, than colorSwitch and projectFile is mandatory parameters.
- In case of ocrEngine is tesseract than colorSwitch, tesseractVersion and cmdLanguage is mandatory parameters.
- If colorSwitch is ON, input image can be tif/png.
- 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:
- Batch Class Identifier should be an existing one.
- 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 :-
- 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:-
- 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:-
- Batch Instance identifier should be valid identifier and having access by the user which are authenticate the web service.
- 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:-
- 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] = newFilePart(file.getName(), file); MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams()); mPost.setRequestEntity(entity); int statusCode = client.executeMethod(mPost);if (statusCode == 200) { System.out.println(“Web service executed successfully.”); String responseBody = mPost.getResponseBodyAsString();
// Generating result as responseBody.
System.out.println(statusCode + ” *** ” + responseBody); } 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:-
- If UseExisting is “true”, existing batch class will be overwriting with the Folders and Script as well as others parameter.
- If UseExisting is “false”, new batch class will created and Folders and Scripts will be used as false.
- If UseSource is “true”, new batch class will have same Name, Description and Priority as source batch class.
- 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:-
- 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:-
- 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:-
- The value for batchClassIdentifier is compulsory and should be valid with permissions to the user to run the batch on it.
- 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] = newFilePart(file.getName(), file); MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams()); mPost.setRequestEntity(entity); int statusCode = client.executeMethod(mPost);if (statusCode == 200) { System.out.println(“Web service executed successfully.”); String responseBody = mPost.getResponseBodyAsString();
// Generating result as responseBody.
System.out.println(statusCode + ” *** ” + responseBody); } 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:-
- documentTypeName should be unique and non-empty.
- minConfidenceThreshold should be a value between 0 and 100.
- formProcessingProjectFile should be a name of pre-existing RSP file.
- 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] = newFilePart(file.getName(), file); MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams()); mPost.setRequestEntity(entity); int statusCode = client.executeMethod(mPost);if (statusCode == 200) { System.out.println(“Web service executed successfully.”); String responseBody = mPost.getResponseBodyAsString();
// Generating result as responseBody.
System.out.println(statusCode + ” *** ” + responseBody); } 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:
- XML and other required learning files are attached with the request.
- Name of learning files mentioned in the XML must match with the file name uploaded with the request.
- XMl format must be same as it shown in Sample XML format. Don’t rearrange the xml elements.
- batch_class_id, doc_type_name, learning_type, are mandatory information and must need to be specified. User cannot omit these fields.
- 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 ).
- 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.
- In a xml file there needs to be single batch_class_id, but there can be multiple <doc_type>. Inside a doc_typethere can only one doc_type_name, learning_type , page_type_first, page_type_middle, page_type_last block.
- 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 = newHttpClient(); String url = “http://localhost:8080/dcma/rest/batchClass/uploadLearningFile“; PostMethod mPost = new PostMethod(url);
// Adding Input XML file for processing File file = new File(“C:\\sample\\Input.xml”); File file1 = newFile(“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 = newMultipartRequestEntity(parts, mPost.getParams()); mPost.setRequestEntity(entity); int statusCode = client.executeMethod(mPost); if (statusCode == 200) { System.out.println(“Web service executed successfully.”); String responseBody = mPost.getResponseBodyAsString(); // Generating result as responseBody. System.out.println(statusCode + ” *** ” + responseBody); } 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
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.
Batch XML is the output for this web service.
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.
// Generating result as responseBody.
This web service searches the input text passed as a parameter for Document Fuzzy.
// Generating result as responseBody.
This web service searches the input text passed as a parameter for Field Fuzzy.
// Generating result as responseBody.
This web service is used for fuzzy database learning based on the input parameters.
In case only batchClassIdentifier is passed as input parameter in the API, learning is done for all the document types within the batch class.
In case batchClassIdentifier and documentType is passed as input parameters in the API, Document Fuzzy learning is done for the input document type.
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.
System.out.println(“Web service executed successfully.”);
// Generating result as responseBody.
System.out.println(statusCode + ” *** ” + responseBody);
System.out.println(“Invalid username/password.”);
System.out.println(mPost.getResponseBodyAsString());
System.err.println(“File not found for processing.”);