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 first, second, third and last page. For Windows a default page processing file is picked by default in case no file is mapped against the documents in the batch class. In case of Linux if no files are mapped against the pages, no extraction is performed. Backward compatibility has been enabled where the web service will allow old set of input parameters as well as the modified ones. With old set of input parameter extraction will be performed on the input image according to the RSP/ZON file depending upon the environment being Windows or Linux respectively.

Request Method POST

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

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

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.

Sample XML

<WebServiceParams>

<Params>

<Param>

<Name>batchClassIdentifier</Name>

<Value>BC8</Value>

</Param>

<Param>

<Name>docType</Name>

<Value>US Invoice</Value>

</Param>

</Params>

</WebServiceParams>

Alternate (old) Input Parameters

Alternate Input parameters to the Web Service API would be three files

  • Tiff/PNG (single page or multipage)
  • XML file, with colorSwitch and projectFile as parameters.
  • Page processing file

Sample XML

<WebServiceParams>

<Params>

<Param>

<Name>colorSwitch</Name>

<Value>OFF</Value>

</Param>

<Param>

<Name>projectFile</Name>

<Value>US_INVOICE.rsp</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 for the first set of input parameters:-

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

Was this article helpful to you?

Engineering