This API will extract the document level fields for the document type for the specified batch class using regular regex extraction.

Request Method POST

Input Parameters

Input Parameter Values Descriptions
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.

 

An input string parameter hocrFile is to be supplied to denote the name of the HOCR file input to the web service.

 

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

Sample XML file

<WebServiceParams>

<Params>

<Param>

<Name>documentType</Name>

<Value>US Invoice</Value>

</Param>

<Param>

<Name>batchClassIdentifier</Name>

<Value>BC5</Value>

</Param>

<Param>

<Name>hocrFileName</Name>

<Value>US-Invoice_HOCR.xml</Value>

</Param>

</Params>

</WebServiceParams>

 

CheckList:-

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

 

Sample client code using apache commons http client:-

private static void extractFieldsUsingRegex() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/extractFieldsUsingRegex";
		PostMethod mPost = new PostMethod(url);
		File file1 = new File("C:\\sample\\sample.xml");
		// adding xml file for taking input
		File file2 = new File("C:\\sample\\US-Invoice_HOCR.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("hocrFile ", file2.getName());
			MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
			mPost.setRequestEntity(entity);
			int statusCode = client.executeMethod(mPost);
			if (statusCode == 200) {
				System.out.println("Web service executed successfully.");
				System.out.println(mPost.getResponseBodyAsString());
			} else if (statusCode == 403) {
				System.out.println("Invalid username/password.");
			} else {
				System.out.println(mPost.getResponseBodyAsString());
			}
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (mPost != null) {
				mPost.releaseConnection();
			}
		}
	}

Was this article helpful to you?

Engineering

Comments are closed.