This API will upload files for learning for a particular document type in a batch class to

  • Shared Folder\ [BatchClassID]\lucene-search-classification-sample folder

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

  • 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

  • Both (image-classifiation and lucene) depending upon input parameters supplied.

This Web Service API can upload files (tif/tiff) for multiple document type of a batch class. Only files will be uploaded to the respective folders.

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 Parameters: Input parameters are a XML file and tiff file/files

XML file Input parameters

Input Parameter Values Descriptions
batch_class_id This value should be an existing batch class Id. This Parameter specifies the Batch Class Id for which learning of files is needed
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
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 need to be

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

Sample XML file format:







<doc_type_name>US Invoice</doc_type_name>






































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. Rearrangement of the xml is not allowed.
  • 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_type there 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 folder need to follow a specific structure. {} à {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:-

private static void uploadLearningFile() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/batchClass/uploadLearningFile";
		PostMethod mPost = new PostMethod(url);
		// Adding Input XML file for processing
		File file = new File("C:\\sample\\sample.xml");
		File file1 = new File("C:\\sample\\US-Invoice.tif");
		File file2 = new File("C:\\sample\\US-Invoice2.tif");
		File file3 = new File("C:\\sample\\US-Invoice3.tif");

		Part[] parts = new Part[4];
		try {
			parts[0] = new FilePart(file.getName(), file);
			parts[1] = new FilePart(file1.getName(), file1);
			parts[2] = new FilePart(file2.getName(), file2);
			parts[3] = new FilePart(file2.getName(), file3);

			MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
			// send post request to server
			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 {
		} catch (HttpException e) {
		} catch (IOException e) {
		} finally {
			if (mPost != null) {

Was this article helpful to you?