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

Request Method POST

Input Parameters

Input Parameter Values Descriptions
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_FILE HOCR XML/(s) zipped to a folder name should be specified ZIP 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.

 

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

Check List:-

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

Sample Input XML:

<KV_Extraction_DocType>

<Batch_Class>BC5</Batch_Class>

<Document_Type>US Invoice</Document_Type>

<HOCR_File>US-Invoice_HOCR.zip</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:-

private static void extractKVForDocumentType () {
		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\\sample.xml");
		File hocrZipFile = new File("C:\\sample\\US-Invoice_HOCR.zip");
		Part[] parts = new Part[2];
		try {
			parts[0] = new FilePart(file.getName(), file);
			parts[1] = new FilePart(hocrZipFile.getName(), hocrZipFile);
			MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
			mPost.setRequestEntity(entity);
			int statusCode = client.executeMethod(mPost);
			if (statusCode == 200) {
				System.out.println("Web service executed successfully.");
				String responseBody = mPost.getResponseBodyAsString();
				// Generating result as responseBody.
				System.out.println(statusCode + " *** " + responseBody);
			} else if (statusCode == 403) {
				System.out.println("Invalid username/password.");
			} else {
				System.out.println(mPost.getResponseBodyAsString());
			}
		} catch (FileNotFoundException e) {
			System.err.println("File not found for processing.");
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (mPost != null) {
				mPost.releaseConnection();
			}
		}
	}

Was this article helpful to you?

Engineering