ABBYY Flexicapture web service call

  • 1.1K Views
  • Last Post 16 January 2018
mgarg posted this 13 February 2017

 Hello,

I have a created Flexicapture project which has 2 flexilayout templates. I have tested the FC project with a sample file using hot folders and it generates the output files. the project is configured to use a batch type (batchtypeId = 4).

I currently have a export file path configured on the General tab of the FC project properties. when i execute the code, the code is able to send the files to the server, the files are recognized and then I can see the output files being generated in the output folder.

The external file storage setting is disabled so the project information is stored in DB

I am trying to integrate the project with my application using the web services API. Below is the code snippet for this.

The statement  Flexicapture.File attachedFile = client.LoadDocumentResult(document.Id, "MyResult.xml") returns a file with null bytes. there is however other file related information in the object such as the templatename, total symbols etc

If I remove the Export file path from the project properties, the bytes are still null 

Can anyone provide guidance on this issue?

Code

--------------------------

var client = new FlexiCaptureWebServiceSoapClient();          

client.ClientCredentials.UserName.UserName = "us\\abcd";

client.ClientCredentials.UserName.Password = "20w345uwrewrx333";

int roleType = 12;

int stationType = 10;

var sessionId = client.OpenSession(roleType, stationType);

var projectId = client.OpenProject(sessionId, "D232S-DF29-33A3-83GC-31E6DFD32359");

            try

            { 

                var userId = client.FindUser("us\\abcd");

                var batch = new Batch();

                batch.Name = "MGTestBatch";

                batch.Description = "MGTestBatch";

                batch.ErrorText = "";

                batch.Id = 0;

                batch.BatchTypeId = 4;

                batch.Priority = 0;

                var batchId = client.AddNewBatch(sessionId, projectId, batch, userId);

                Flexicapture.File file1 = LoadFile("C:\\Test1\\Test file - revised (554390).pdf");

                client.AddNewImage(sessionId, batchId, file1);

                client.ProcessBatch(sessionId, batchId);

                int percentCompleted = 0;

                while (percentCompleted < 100)

                {

                    percentCompleted = client.GetBatchPercentCompleted(batchId);

                    System.Threading.Thread.Sleep(500);

                }

                var documents = client.GetDocuments(batchId)

                if (documents != null)

                {

                    foreach(Flexicapture.Document document in documents)

                    {

                        Flexicapture.File attachedFile = client.LoadDocumentResult(document.Id, "MyResult.xml");

                    }

                }

                client.DeleteBatch(sessionId, batchId);

                client.CloseProject(sessionId, projectId);

            }catch(Exception ex)

            {

                var x = ex.Message;

            }

            finally

            {

                client.CloseSession(sessionId);

            }

Order By: Standard | Newest | Votes
Ekaterina posted this 20 February 2017

Hello,

Please use the FlexiCaptureWebServiceApiVersion3 as described here: Application Programming Interface (API) > Examples of API Use instead of the FlexiCaptureWebServiceSoapClient.

Nirav Pradhan posted this 22 November 2017

In the code sample provided above, where  batch.Priority = 0. What are other priority levels, and how are they represented numerically?

Vladimir Dimitrijevic posted this 23 November 2017

Hi Nirav,

Here is the list of priorities: http://help.abbyy.com/en-us/flexicapture/12/developer/tprocessingpriority_appendixscripts 

 

Best regards,

Vladimir

 

CarlChan posted this 12 January 2018

Hello,

We have developed a program to upload a image file to FlexiCapture 11 and return recognition result via Web Service API. 
I am currently working with FC12,the FlexiCaptureWebServiceApiVersion3 seems changed to FlexiCaptureWebServiceApi.

  • Is there any sample code about the new API? (there was sample code in FC11 Help File but are removed in FC12 Help File)
  • I received error "SOAP Server Application Faulted" when calling AddNewImage(sessionId, batchId, file). When I look at the Windows Event Viewer of the FlexiCapture Server, I saw error message "ABBYY FlexiCapture Web Services: Batch is not opened." It was not needed to call OpenBatch(sessionId, batchId); in FC11, and it is not mentioned in FC12 Help File...

  • After adding a line of OpenBatch(sessionId, batchId) before calling AddNewImage(sessionId, batchId, file),I do not get "SOAP Server Application Faulted" any more, but I am still unable to upload any image (no exception but no file was uploaded). 

Ekaterina posted this 15 January 2018

Hello,

Sorry, the samples for FlexiCapture 12 are still in progress and are not available for the moment. If you need future consultation please contact your regional support.

Prasad posted this 15 January 2018

Hi CarlChan

We have had issues with with FlexiCapture Version 12 Web Services as well. we have been able to resolve some Issues while we have reached out to ABBYY Support for the rest. we have used the AFC 11 Web Service API sample (https://knowledgebase.abbyy.com/article/1271API Batch Browser” as the base of our testing.

 

We have been able to load a Multi page PDF file using the following steps 

1. Create New Batch

2. Open Batch 

3. Add Multipage PDF file

4. Process Batch

5. Close Batch

see below for sample code

                            if (File != null)

                            {

                                service.OpenBatch(sessionId, batchId);

                                FlexiCapture12API.Document doc = createNewDocument();

                                service.AddNewDocument(sessionId, doc, File, true, 0);

                                service.ProcessBatch(sessionId, batchId);

                                ProgressBarForm Progress = new ProgressBarForm();

                                Progress.bgw_Processing.DoWork += bgw_Processing_DoWork;

                                Progress.ShowDialog();

                                ShowDocuments();

                                service.CloseBatch(sessionId, batchId);

                            }

Listed below are the results of testing with some of the Functions in the sample.

  1. Create Batch – Working, Batch ends in the Out of Workflow Que
  2. Delete Batch – Working as Expected
  3. Add Document (Multipage) 
    1.  Working when used in association with Create Batch.
    2.  Working when the Batch is in the “Processed Stage”, Batch ends in the Out of Workflow Que.
    3.  Any other stage we get an error and when checked with application logs it indicates that there is a Locking Issues which is recorded as an error (ABBYY FlexiCapture Web Services: Cannot lock document.) and a Warning (ABBYY FlexiCapture Web Services: ERR_DBMGR_DOCUMENT_IS_ALREADY_LOCKED_BY_SESSION 0).
  4. Delete Document (Multipage) 
    1. Working when the Batch is in the “Processed Stage”, Batch ends in the Out of Workflow Que.
    2. Any other stage we get an error and when checked with application logs it indicates that there is a Locking Issues which is recorded as an error (ABBYY FlexiCapture Web Services: Cannot lock document.) and a Warning (ABBYY FlexiCapture Web Services: ERR_DBMGR_DOCUMENT_IS_ALREADY_LOCKED_BY_SESSION 0).
  5. Delete Page 
    1. working when the Batch is in the “Processed Stage”, Batch ends in the Out of Workflow Que.
    2. Any other stage we get an error and when checked with application logs it indicates that there is a Locking Issues which is recorded as an error (ABBYY FlexiCapture Web Services: Cannot lock document.) and a Warning (ABBYY FlexiCapture Web Services: ERR_DBMGR_DOCUMENT_IS_ALREADY_LOCKED_BY_SESSION 0).
  6. Edit Document Registration Parameters 
    1. working when the Batch is in the “Processed Stage”, Batch ends in the Out of Workflow Que if ProcessBatch() is not called, if it is called the batch goes to verification.
    2. Any other stage we get an error and when checked with application logs it indicates that there is a Locking Issues which is recorded as an error (ABBYY FlexiCapture Web Services: Cannot lock document.) and a Warning (ABBYY FlexiCapture Web Services: ERR_DBMGR_DOCUMENT_IS_ALREADY_LOCKED_BY_SESSION 0).
  7. The other function have not been tested yet.

Hope this helps

Thanks and Regards

Prasad

 

  • Liked by
  • CarlChan
CarlChan posted this 16 January 2018

Hi Prasad,

 

Your reply is awesome!!

I finally able to upload image to the FC12 server!

 

The solution is just adding a single line of code, before creating a new batch

batch.StageExternalId = 900

 

 

It is very strange that I have to set the processing stage to be "Processed", before I import image and process the new batch.......

 

Anyway, I'm very happy that we can use Web API in FC12 now : )

Close