{"id":31705,"date":"2018-11-20T23:27:32","date_gmt":"2018-11-21T07:27:32","guid":{"rendered":"https:\/\/ephesoft.com\/docs\/2019-1-2\/developers\/web-services-api\/transact-web-service-definitions\/"},"modified":"2021-06-11T12:45:42","modified_gmt":"2021-06-11T19:45:42","slug":"transact-web-service-definitions","status":"publish","type":"docs","link":"https:\/\/ephesoft.com\/docs\/products\/transact\/developers\/web-services-api\/transact-web-service-definitions\/","title":{"rendered":"Web Service Definitions and Code Samples"},"content":{"rendered":"
The Ephesoft Transact web services API provides a simple method for real-time integration and exposure of Ephesoft processes to external applications. This allows developers to embed and employ advanced capture capabilities and technologies in content management systems and other workflows.<\/p>\n
Ephesoft Transact web services support the OpenAPI standard, and the Ephesoft Transact Web Services Explorer utilizes the Swagger interface to enable documentation and testing for Ephesoft Transact web services. Web services that return XML responses can be tested directly in the Swagger interface, but due to a limitation of the Swagger interface, web services that return non-XML responses cannot. Refer to the\u00a0Swagger\/OpenAPI Capabilities<\/b>\u00a0section of each web service for information about whether a web service supports being tested directly in the Swagger interface or not. All Ephesoft Transact web services, including those that can’t be tested in the Swagger interface, can still be tested in other web service testing tools, such as Postman.<\/p>\n
This document provides a brief description of each web service followed by a code sample showing how the web service can be used.\u00a0 All code samples are written in Java and utilize the Apache Commons HttpClient library.<\/p>\n
Web services on this page are grouped into the following sections:<\/p>\n
When Ephesoft Transact web services are used in an API development tool like Postman or Swagger, basic authentication must be provided in the http request header. For example:<\/p>\n
Authorization:Basic ephesoft:demo (username and password should be encoded in Base64)<\/em><\/pre>\nWhen Ephesoft Transact web services are used in Java code, client call authentication can be handled like this:<\/p>\n
Credentials defaultcreds = new UsernamePasswordCredentials(\"username\", \"password\");\r\nclient.getState().setCredentials(new AuthScope(\"serverName\", 8080), defaultcreds);<\/pre>\n
\nBatch Class Management Web Services<\/h2>\n
copyBatchClass<\/h3>\n
This web service creates a copy of an existing batch class.<\/p>\n
Request Method:\u00a0<\/b>POST<\/p>\n
Web Service URL:\u00a0<\/b>http:\/\/{serverName}:{port}\/dcma\/rest\/batchClass\/copyBatchClass<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/pre>\nprivate static void createBatchClass() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/{serverName}:{port}\/dcma\/rest\/batchClass\/copyBatchClass\";\r\n PostMethod mPost = new PostMethod(url);\r\n \/\/ Adding Input XML file for processing\r\n File file = new File(\"C:\\sample\\Input.xml\");\r\n Part[] parts = new Part[1];\r\n try {\r\n parts[0] = newFilePart(file.getName(), file);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n \/\/ Generating result as responseBody.\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n }\r\n else if(statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\ncopyDocumentType<\/h3>\n
This web service copies an existing document type to create a new document type in the same batch class.<\/p>\n
Request Method:\u00a0<\/b>POST<\/p>\n
Web Service URL:\u00a0<\/b>http:\/\/{serverName}:{port}\/dcma\/rest\/batchClass\/copyDocumentType<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void copyDocumentType() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/batchClass\/copyDocumentType\";\r\n PostMethod mPost = new PostMethod(url);\r\n \/\/ Adding Input XML file for processing\r\n File file = new File(\"C:\\sample\\Input.xml\");\r\n Part[] parts = new Part[1];\r\n try {\r\n parts[0] = new FilePart(file.getName(), file);\r\n MultipartRequestEntity entity = newMultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n \/\/ Generating result as responseBody.\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\ndocumentTypeCreator<\/span><\/span><\/h3>\n
This web service creates a new document type.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/batchClass\/documentTypeCreator<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void createDocumentType() {\r\n HttpClient client = new HttpClient();\r\n String url = \u201chttp: \/\/localhost:8080\/dcma\/rest\/batchClass\/documentTypeCreator\u201c; PostMethod mPost = new PostMethod(url);\r\n \/\/ Adding Input XML file for processing\r\n File file = new File(\u201cC: \\sample\\ Input.xml\u201d);\r\n Part[] parts = new Part[1];\r\n try {\r\n parts[0] = newFilePart(file.getName(), file);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\u201cWeb service executed successfully.\u201d);\r\n String responseBody = mPost.getResponseBodyAsString();\r\n \/\/ Generating result as responseBody.\r\n System.out.println(statusCode + \u201d ** * \u201d+responseBody);\r\n }\r\n else if(statusCode == 403) {\r\n System.out.println(\u201cInvalid username \/ password.\u201d);\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\u201cFile not found\r\n for processing.\u201d);\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nexportBatchClass<\/span><\/span><\/h3>\n
This web service exports a batch class.<\/p>\n
Request Method:<\/b> POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/exportBatchClass<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private\u00a0static void exportBatchClass() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/exportBatchClass\";\r\n PostMethod mPost = new PostMethod(url);\r\n mPost.addParameter(\"identifier\", \"BC1\");\r\n mPost.addParameter(\"lucene-search-classification-sample\", \"true\");\r\n mPost.addParameter(\"image-classification-sample\", \"false\");\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Batch class exported successfully\");\r\n InputStream in = mPost.getResponseBodyAsStream();\r\n File f = new File(\"C:\\sample\\serverOutput.zip\");\r\n FileOutputStream fos = new FileOutputStream(f);\r\n try {\r\n byte[] buf = newbyte[1024];\r\n int len = in .read(buf);\r\n while (len > 0) {\r\n fos.write(buf, 0, len);\r\n len = in .read(buf);\r\n }\r\n } finally {\r\n if (fos != null) {\r\n fos.close();\r\n }\r\n }\r\n }\r\n else if(statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\ngetAllModulesWorkflowNameByBatchClass<\/span><\/span><\/h3>\n
This web service returns the module names and module workflow names for the specified batch class.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/getAllModulesWorkflowNameByBatchClass\/{batchClassIdentifier}<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void getAllModulesWorkflowNameByBatchClass() {\r\n HttpClient client = new HttpClient();\r\n \/\/ URL path to be hit for getting the mdoule workflow name of the specified batch class identifier\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/getAllModulesWorkflowNameByBatchClass\/BC1\";\r\n GetMethod getMethod = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(getMethod);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = getMethod.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(getMethod.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (getMethod != null) {\r\n getMethod.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\ngetBatchClassFields<\/h3>\n
This web service returns the batch class fields of the supplied batch class identifier. The batch class fields are only returned if the batch class is accessible to the user.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/getBatchClassFields\/{batchClassIdentifier}<\/p>\n
\ngetBatchClassForRole<\/span><\/span><\/h3>\n
This web service retrieves a list of all batch classes accessible to the specified user role.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL:<\/strong>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/getBatchClassForRole\/{role}<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void getBatchClassForRole() {\r\n HttpClient client = new HttpClient();\r\n \/\/ URL path to be hit for getting the batch class list having accessed by the role specified.\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/getBatchClassForRole\/admin\";\r\n GetMethod getMethod = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(getMethod);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = getMethod.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(getMethod.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (getMethod != null) {\r\n getMethod.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\ngetBatchClassList<\/h3>\n
This web service returns a list of all batch classes accessible by the authenticated user.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/getBatchClassList<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void getBatchClassList() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/getBatchClassList\";\r\n GetMethod mGet = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(mGet);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mGet.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n }\r\n else if(statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mGet.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mGet != null) {\r\n mGet.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\ngetRoles<\/h3>\n
This web service retrieves all roles for a given batch class.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/getRoles\/{batchClassIdentifier}<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void getRoles() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/getRoles\/BC1\";\r\n GetMethod mGet = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(mGet);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mGet.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n }\r\n else if(statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mGet.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mGet != null) {\r\n mGet.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nimportBatchClass<\/span><\/span><\/h3>\n
This web service imports a batch class into Ephesoft Transact.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0 http:\/\/{serverName}:{port}\/dcma\/rest\/importBatchClass<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void importBatchClass() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/importBatchClass\";\r\n PostMethod mPost = new PostMethod(url);\r\n mPost.setDoAuthentication(true);\r\n \/\/ Input XML for adding parameter.\r\n File file1 = new File(\"C:\\sample\\importbatchclass.xml\");\r\n \/\/ Input zip file for importing batch class.\r\n File file2 = new File(\"C:\\sample\\BC1_050712_1714.zip\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new FilePart(file2.getName(), file2);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Batch class imported successfully\");\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.out.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nlearnFile<\/span><\/span><\/h3>\n
This web service will learn all the files present in the search classification and image classification learning folders of the batch class. This web service supports using a PDF file\u2019s EText layer for OCR, provided that the batch class has been configured accordingly to support that processing method.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/batchClass\/learnFile\/{BatchClassIdentifier}<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void fileLearningService() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/batchClass\/learnFile\/{BatchClassIdentifier}\";\r\n PostMethod mPost = new PostMethod(url);\r\n try {\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n \/\/ Generating result as responseBody.\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nlearnFuzzyDatabase<\/span><\/h3>\n
This web service performs database learning for the Fuzzy DB feature. The database table to be learned is based on the \u2018Document Fuzzy\u2019 and \u2018Field Fuzzy\u2019 configurations defined inside the document type of the batch class. This web service emulates clicking the LearnDB command in the Transact user interface.<\/p>\n
Request Method:\u00a0<\/span><\/strong>POST<\/p>\n
Web Service URL:<\/strong>\u00a0<\/span>http:\/\/<hostname>:<port>\/dcma\/rest\/\u00a0batchClass\/learnFuzzyDatabase<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void learnFuzzyDatabase() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/learnFuzzyDatabase\";\r\n PostMethod mPost = new PostMethod(url);\r\n \/\/ adding file for sending\r\n Part[] parts = new Part[4];\r\n try {\r\n parts[0] = new StringPart(\"batchClassIdentifier\", \"BC1\");\r\n parts[1] = new StringPart(\"documentType\", \"Invoice-Table\");\r\n parts[2] = new StringPart(\"groupNames\", \"*\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n \/\/ Generating result as responseBody.\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nuploadLearningFile<\/h3>\n
This web service uploads learning files for one or more document types in a batch class. As opposed to the uploadLearnFile web service, which automatically places pages in the appropriate first\/middle\/last folders based on their positions in the uploaded files, this web service allows the developer to choose the exact folder (first, middle or last) where individual pages will be placed. The files are uploaded to one or more of the following folders depending on the \u2018learning_type\u2019 value defined in the web service parameters file.<\/p>\n
Request Method:\u00a0<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/batchClass\/uploadLearningFile<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void learnFile() {\r\n HttpClient client = newHttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/batchClass\/uploadLearningFile\";\r\n PostMethod mPost = new PostMethod(url);\r\n \/\/ Adding Input XML file for processing\r\n File file = new File(\"C:\\sample\\Input.xml\");\r\n File file1 = new File(\"C:\\sample\\first.tif\");\r\n File file2 = new File(\"C:\\sample\\second.tif\");\r\n Part[] parts = new Part[number of files need to be uploaded];\r\n try {\r\n parts[0] = new FilePart(file.getName(), file);\r\n parts[1] = new FilePart(file1.getName(), file1);\r\n parts[2] = new FilePart(file2.getName(), file2);\r\n parts[n] = new FilePart(filen.getName(), filen);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n \/\/ send post request to server\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n \/\/ Generating result as responseBody.\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nuploadLearnFiles<\/h3>\n
This web service uploads files to the specified learning folder of a batch class based on the specified learning type. This web service approximates the process of learning files through the Transact user interface, where the user only needs to supply the batch class, document type, learning type, and files, and the web services will distribute the individual pages into the appropriate first, middle and last page folders in the operating system automatically.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0 http:\/\/{serverName}:{port}\/dcma\/rest\/batchClass\/uploadLearnFiles<\/p>\n
\nBatch Instance Management Web Services<\/h2>\n
AddUserRolesToBatchInstance<\/span><\/span><\/h3>\n
This web service adds a user role to a batch instance.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL:<\/b>\u00a0 http:\/\/{serverName}:{port}\/dcma\/rest\/AddUserRolesToBatchInstance\/{batchInstanceIdentifier}\/{userRole}<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void addUserRolesToBatchInstance() {\r\n HttpClient client = new HttpClient();\r\n \/\/ URL path to be hit for adding user roles to batch instance identifier\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/addUserRolesToBatchInstance\/BI45\/admin\";\r\n GetMethod getMethod = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(getMethod);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = getMethod.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(getMethod.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (getMethod != null) {\r\n getMethod.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\nBatchInstanceList<\/span><\/span><\/h3>\n
This web service returns a list of batch instances with the specified status. If the user is the super admin user, all batch instances with the specified status will be returned. If the user is not the super admin user, only batch instances that can be accessed by the user will be returned. The following details will be returned for each batch instance: batch name, executed modules, local folder, review operator, batch identifier, drop folder.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL<\/b>:<\/strong>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/BatchInstanceList\/{status}<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void getBatchInstanceList() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/BatchInstanceList\/RUNNING\";\r\n GetMethod getMethod = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(getMethod);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = getMethod.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(getMethod.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (getMethod != null) {\r\n getMethod.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\ndeleteBatchInstance<\/span><\/span><\/h3>\n
This web service is used to delete a batch instance. The batch instance will be deleted only if the batch instance is not locked by any user, and is in one of the following states: Error, Running, Ready for Review, or Ready for Validation. Note that the user must be authenticated and must have access to the batch instance being deleted.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/deleteBatchInstance\/{identifier}<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void deleteBatchInstance() {\r\n HttpClient client = new HttpClient();\r\n \/\/ User can only delete batch instances with statuses of ERROR, READY_FOR_REVIEW, READY_FOR_VALIDATION, or RUNNING\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/deleteBatchInstance\/BI1\";\r\n GetMethod getMethod = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(getMethod);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = getMethod.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(getMethod.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (getMethod != null) {\r\n getMethod.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\ngetBatchInstanceForRole<\/span><\/span><\/h3>\n
This web service retrieves the list of batch instances accessible to a particular role.<\/p>\n
Request Method:<\/b>\u00a0GET<\/p>\n
Web Service URL:\u00a0<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/getBatchInstanceForRole\/{role}<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void getBatchInstanceForRole() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/getBatchInstanceForRoles\/admin\";\r\n GetMethod getMethod = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(getMethod);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = getMethod.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(getMethod.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (getMethod != null) {\r\n getMethod.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nBatch Instance Processing Web Services<\/h2>\n
advancedBarcodeExtraction<\/span><\/h3>\n
This web service performs barcode extraction on the input document based on the configuration options provided in the parameters.xml file. The settings for the ADVANCED_BARCODE_EXTRACTION plugin for the supplied batch class identifier are retrieved and used to perform the extraction.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:\u00a0<\/span><\/strong>http:\/\/<HOSTNAME>:8080\/dcma\/rest\/advancedBarcodeExtraction<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void advancedBarcodeExtraction() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/advancedBarcodeExtraction\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"C:\\sample\\sample.xml\");\r\n \/\/ adding xml file for taking input\r\n File file2 = new File(\"C:\\sample\\US-Invoice.tif\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new FilePart(file2.getName(), file2);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n System.out.println(mPost.getResponseBodyAsString());\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nadvancedUploadBatch<\/h3>\n
This web service uploads a new batch to the identified batch class\u2019s drop folder.<\/p>\n
Request Type:<\/strong> POST<\/p>\n
Request URL:<\/strong> {ProtocolType}:\/\/{ServerIP}:{ServerPort}\/dcma\/rest\/advancedUploadBatch<\/p>\n
Sample URL:<\/strong> http:\/\/localhost:8080\/dcma\/rest\/advancedUploadBatch<\/p>\n
<\/p>\n
Sample Input XML<\/strong><\/p>\n
<Upload_Batch>\r\n <BatchClassIdentifier>BC1<\/BatchClassIdentifier>\r\n <BatchClassFields>\r\n <BatchClassField>\r\n <Name>Test1<\/Name>\r\n <Value>123<\/Value>\r\n <\/BatchClassField>\r\n <BatchClassField>\r\n <Name>Test2<\/Name>\r\n <Value>456<\/Value>\r\n <\/BatchClassField>\r\n <\/BatchClassFields>\r\n <BatchInstanceName>SampleBatch<\/BatchInstanceName>\r\n <BatchDescription>SampleDesc<\/BatchDescription>\r\n <BatchPriority>20<\/BatchPriority>\r\n<\/Upload_Batch><\/code><\/pre>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
HttpClient client = new HttpClient();\r\nString url = \"http:\/\/localhost:8080\/dcma\/rest\/advancedUploadBatch\";\r\nPostMethod mPost = new PostMethod(url);\r\nFile file1 = new File(\"C:\\sample\\advancedUploadBatch.xml\");\r\nFile file2 = new File(\"C:\\sample\\US-Invoice.tiff\");\r\nPart[] parts = new Part[2];\r\ntry {\r\n \/\/ Input XML\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n \/\/ File for processing\r\n parts[1] = new FilePart(file2.getName(), file2);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n} catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n} catch (IOException e) {\r\n e.printStackTrace();\r\n} finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n}\r\n<\/pre>\n
\nbarcodeExtraction<\/span><\/span><\/h3>\n
This web service performs barcode extraction on the input document based on the configuration options provided in the parameters.xml file. The settings for the ADVANCED_BARCODE_EXTRACTION plugin for the supplied batch class identifier are retrieved and used to perform the extraction.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/barcodeExtraction<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void barcodeExtraction() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/barcodeExtraction\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"C:\\sample\\sample.tif\");\r\n \/\/ adding xml file for taking input\r\n File file2 = new File(\"C:\\sample\\WebServiceParams-barcodeExtraction.xml\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new FilePart(file2.getName(), file2);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n System.out.println(mPost.getResponseBodyAsString());\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\ncheckWSStatus<\/h3>\n
This web service queries the current status of the initiateOcrClassifyExtract web service.<\/p>\n
Service Request: <\/strong>GET<\/p>\n
Web Service URL:\u00a0<\/strong>http:\/\/{serverName}:{port}\/dcma\/rest\/checkWSStatus<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/h4>\n
private static void checkWSStatus() {\r\n HttpClient client = new HttpClient();\r\n String url = \" http:\/\/localhost:8080\/dcma\/rest\/checkWSStatus?ocrToken=1233232323 \";\r\n GetMethod getMethod = new GetMethod(url);\r\n int statusCode;\r\n try {\r\n statusCode = client.executeMethod(getMethod);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = getMethod.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(getMethod.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (getMethod != null) {\r\n getMethod.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nclassifyBarcodeImage<\/h3>\n
This web service is used to classify the supplied image using a barcode according to the specified batch class. The image file should contain a barcode and the barcode value should represent a document type that exists in the batch class.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/classifyBarcodeImage<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void classifyBarcodeImage() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/locahost:8080\/dcma\/rest\/classifyBarcodeImage\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"C:\\sample\\US-Invoice.tif\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new StringPart(\"batchClassId\", \"BC1\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\nclassifyHocr<\/h3>\n
This web service classifies the input HOCR.xml according to the batch class identifier provided. The appropriate classification and assembly plugins must be configured in the batch class. Document learning must be performed on the batch class before the web service is used. If the batch class doesn\u2019t have the required plugins configured, the web service will not work.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/classifyHocr<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void\u00a0classifyHocr() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/classifyHocr\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"C:\\sample\\US-Invoice.html\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new StringPart(\"batchClassId\", \"BC1\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully..\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nclassifyImage<\/h3>\n
This web service allows developers to classify documents from third party applications without creating batch instances. It performs layout-based classification based on the samples provided in the batch class and returns the document type. The input file to be classified must be a single-page TIFF file. This web service depends on the CREATE_THUMBNAILS, CLASSIFY_IMAGES and DOCUMENT_ASSEMBLER plugins. If the batch class does not contain these plugins the web service will not work.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/classifyImage<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void\u00a0classifyImage() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/classifyImage\";\r\n PostMethod mPost = new PostMethod(url);\r\n \/\/ Adding tif file for processing\r\n File file1 = new File(\"C:\\sample\\US-Invoice.tif\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n \/\/ Adding parameter for batchClassId\r\n parts[1] = new StringPart(\"batchClassId\", \"BC1\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully..\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password..\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing..\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nclassifyMultiPageHocr<\/h3>\n
This web service classifies multiple HOCR.xml files using the batch class identifier provided. The batch class depends on the SEARCH_CLASSIFICATION and DOCUMENT_ASSEMBLER plugins. Document learning must have been performed previously in the batch class.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/classifyMultiPageHocr<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void classifyMultiPageHocr() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/classifyMultiPageHocr\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"D:\\sample\\New folder.zip\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new StringPart(\"batchClassId\", \"BC1\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n String responseBody = mPost.getResponseBodyAsString();\r\n System.out.println(statusCode + \"***\" + responseBody);\r\n mPost.releaseConnection();\r\n } catch (FileNotFoundException e) {\r\n e.printStackTrace();\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n }\r\n}<\/pre>\n
\ncreateHOCRforBatchClass<\/h3>\n
This web service generates HOCR.xml files for TIFF or PDF files.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/batchClass\/createHOCRforBatchClass<\/p>\n
<\/pre>\nSample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void createHOCRXML() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/batchClass\/createHOCRforBatchClass\";\r\n PostMethod mPost = new PostMethod(url);\r\n \/\/ Adding Input XML file for processing\r\n File file = new File(\u201cC:\\sample\\Input.xml\u201d);\r\n File imageFile = new File(\u201cC:\\sample\\SampleImage.tif\u201d);\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file.getName(), file);\r\n parts[1] = new FilePart(imageFile.getName(), imageFile);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\u201cWeb service executed successfully.\u201d);\r\n String responseBody = mPost.getResponseBodyAsString();\r\n \/\/ Generating result as responseBody.\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\ncreateOCR<\/span><\/span><\/h3>\n
This web service will create an HOCR.xml file for the provided image file. Tesseract, Nuance and RecoStar all support conventional OCR processes where a non-TIFF image is converted to TIFF and then OCR\u2019d accordingly. When RecoStar is used as the OCR engine, the EText layer of a PDF file can be used for OCR purposes if the RSP file has ExtractFromEText chosen as the processing mode. If a PNG or TIFF file is processed by the RecoStar OCR engine using an ExtractFromEText RSP file, a blank HOCR.xml file will be returned.<\/p>\n
This web service supports using a PDF file\u2019s EText layer for OCR and extraction, provided that the batch class has been configured accordingly to support that processing method.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/createOCR<\/p>\n
<\/pre>\nSample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void createOCR() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/createOCR\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"C:\\sample\\sample1.tif\");\r\n File file2 = new File(\"C:\\sample\\WebServiceParams.xml\");\r\n File file3 = new File(\"C:\\sample\\Fpr.rsp\");\r\n Part[] parts = new Part[3];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new FilePart(file2.getName(), file2);\r\n parts[2] = new FilePart(file3.getName(), file3);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n InputStream in = mPost.getResponseBodyAsStream();\r\n \/\/ saving result generated.\r\n File outputFile = new File(\"C:\\sample\\serverOutput.zip\");\r\n FileOutputStream fos = new FileOutputStream(outputFile);\r\n try {\r\n byte[] buf = newbyte[1024];\r\n int len = in .read(buf);\r\n while (len > 0) {\r\n fos.write(buf, 0, len);\r\n len = in .read(buf);\r\n }\r\n } finally {\r\n if (fos != null) {\r\n fos.close();\r\n }\r\n }\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\ndecryptBatchInstanceHocrXml<\/h3>\n
This web service decrypts an HOCR.xml file in a batch instance. When a batch is executed in an encrypted batch class, the HOCR.xml files created for the image files are also encrypted. The name of the HOCR.xml file and the batch instance identifier are passed in as parameters.<\/p>\n
Web Service URL:<\/strong>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/decryptBatchInstanceHocrXml<\/p>\n
Request Method: <\/strong>POST<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void decryptBatchInstanceHocrXml() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/decryptBatchInstanceHocrXml\";\r\n PostMethod mPost = new PostMethod(url);\r\n mPost.setDoAuthentication(true);\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new StringPart(\"hocrFileName\", \"BI3_0_HOCR.xml\");\r\n parts[1] = new StringPart(\"batchInstanceIdentifier\", \"BI3\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"HOCR XML decrypted successfully\");\r\n System.out.println(mPost.getResponseBodyAsString());\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.out.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\ndecryptBatchXml<\/h3>\n
This web service decrypts an encrypted batch.xml file (generally found in the final drop folder of a batch instance). Encrypted batch.xml files can only be decrypted on Transact servers that use the same encryption keys as the server that originally encrypted the batch.xml file.<\/p>\n
Request Method: <\/strong>POST<\/p>\n
Web Service URL:<\/strong>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/decryptBatchXml<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void decryptBatchXml() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/decryptBatchXml\";\r\n PostMethod mPost = new PostMethod(url);\r\n mPost.setDoAuthentication(true);\r\n File file1 = new File(\"F:\\Ephesoft\\SharedFolders\\BC5\\Final-drop-folder\\BI2\\BI2_batch.xml\");\r\n Part[] parts = new Part[1];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Batch XML decrypted successfully\");\r\n System.out.println(mPost.getResponseBodyAsString());\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.out.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\ndecryptLuceneClassificationHocrXml<\/h3>\n
This web service decrypts an HOCR.xml file in the lucene-search-classification-sample folder within the batch class folder in the SharedFolders area.<\/p>\n
Web Service URL:<\/strong>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/decryptLuceneClassificationHocrXml<\/p>\n
Request Method: <\/strong>POST<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void decryptLuceneClassificationHocrXml() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/decryptLuceneClassificationHocrXml\";\r\n PostMethod mPost = new PostMethod(url);\r\n mPost.setDoAuthentication(true);\r\n \/\/ Input zip file for importing batch class.\r\n Part[] parts = new Part[4];\r\n try {\r\n parts[0] = new StringPart(\"hocrFileName\", \"US-Invoice_HOCR.xml\");\r\n parts[1] = new StringPart(\"batchClassIdentifier\", \"BC5\");\r\n parts[2] = new StringPart(\"pageType\", \"First\");\r\n parts[3] = new StringPart(\"documentType\", \"US Invoice\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"HOCR XML decrypted successfully\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.out.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\ndecryptTestHocrXml<\/h3>\n
This web service decrypts an HOCR.xml file in one of the test folders within the batch class. Test folders that can be used with the web service are test-advanced-extraction, test-classification, test-extraction and test-table.<\/p>\n
Web Service URL:<\/strong>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/decryptTestHocrXml<\/p>\n
Request Method: <\/strong>POST<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void decryptTestHocrXml() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/decryptTestHocrXml\";\r\n PostMethod mPost = new PostMethod(url);\r\n mPost.setDoAuthentication(true);\r\n Part[] parts = new Part[4];\r\n try {\r\n parts[0] = new StringPart(\"hocrFileName\", \"US-Invoice-0000_HOCR.xml\");\r\n parts[1] = new StringPart(\"batchClassIdentifier\", \"BC5\");\r\n parts[2] = new StringPart(\"testType\", \"table\");\r\n parts[3] = new StringPart(\"documentType\", \"US Invoice\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"HOCR XML decrypted successfully\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.out.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}<\/pre>\n
\nextractFieldFromHocr<\/span><\/span><\/h3>\n
This web service executes key-value extraction for the requested field based on key-value rules defined in the batch class.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/extractFieldFromHocr<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void extractFieldFromHocr() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/extractFieldFromHocr\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"C:\\sample\\Application-Checklist-hocr.xml\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n \/\/ Adding field value for extracting Key Value Pattern.\r\n parts[1] = new StringPart(\"fieldValue\", \"APPLICATION\");\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n String responseBody = mPost.getResponseBodyAsString();\r\n System.out.println(statusCode + \" *** \" + responseBody);\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (FileNotFoundException e) {\r\n System.err.println(\"File not found for processing.\");\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\nextractFields<\/span><\/span><\/h3>\n
This web service provides multiple ways to perform extraction. The header parameter \u201cextractionAPI\u201d specifies the type of extraction to use.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/extractFields<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient (U<\/b>sing the REGULAR_REGEX_EXTRACTION Option)<\/strong><\/p>\n
private static void extractFields() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/extractFields\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"C:\\sample\\input\\sample1.html\");\r\n \/\/ adding xml file for taking input\r\n File file2 = new File(\"C:\\sample\\input\\WebServiceParams.xml\");\r\n Part[] parts = new Part[2];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new FilePart(file2.getName(), file2);\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n \/\/ Pass the name of extraction api that is to be used: BARCODE_EXTRACTION, RECOSTAR_EXTRACTION, REGULAR_REGEX_EXTRACTION, KV_EXTRACTION, FUZZY_DB, NUANCE_EXTRACTION\r\n Header header = new Header(\"extractionAPI\", \"REGULAR_REGEX_EXTRACTION\");\r\n mPost.addRequestHeader(header);\r\n mPost.setRequestEntity(entity);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n System.out.println(mPost.getResponseBodyAsString());\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\nextractFieldsUsingRegex<\/span><\/span><\/h3>\n
This web service extracts values and coordinates based on regular expressions defined for all fields of a particular document type of a particular batch class.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n
Web Service URL:<\/b>\u00a0http:\/\/{serverName}:{port}\/dcma\/rest\/extractFieldsUsingRegex<\/p>\n
Sample Client Code Utilizing Apache Commons HttpClient<\/b><\/p>\n
private static void extractFieldsUsingRegex() {\r\n HttpClient client = new HttpClient();\r\n String url = \"http:\/\/localhost:8080\/dcma\/rest\/extractFieldsUsingRegex\";\r\n PostMethod mPost = new PostMethod(url);\r\n File file1 = new File(\"C:\\sample\\sample1.xml\");\r\n File file2 = new File(\"C:\\sample\\WebServiceParams.xml\");\r\n Part[] parts = new Part[3];\r\n try {\r\n parts[0] = new FilePart(file1.getName(), file1);\r\n parts[1] = new FilePart(file2.getName(), file2);\r\n parts[2] = new StringPart(\u201chocrFileName\u201d, file1.getName());\r\n MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());\r\n mPost.setRequestEntity(entity);\r\n int statusCode = client.executeMethod(mPost);\r\n if (statusCode == 200) {\r\n System.out.println(\"Web service executed successfully.\");\r\n System.out.println(mPost.getResponseBodyAsString());\r\n } else if (statusCode == 403) {\r\n System.out.println(\"Invalid username\/password.\");\r\n } else {\r\n System.out.println(mPost.getResponseBodyAsString());\r\n }\r\n } catch (HttpException e) {\r\n e.printStackTrace();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n } finally {\r\n if (mPost != null) {\r\n mPost.releaseConnection();\r\n }\r\n }\r\n}\r\n<\/pre>\n
\nextractFixedForm<\/span><\/span><\/h3>\n
This web service provides two different processing options for extracting fixed-form data. Different XML parameter input file formats are needed depending on the option chosen.<\/p>\n
Request Method:<\/b>\u00a0POST<\/p>\n