Send a tcp request to a identification document scanner


I have to communicate with an ID document scanner to get the data that will be read by it. I have to send a request with certain parameters and receive the data through an xml file.

The parameters to send are the ones below

Send Request Parameters.jpg

I have an example in C # and, according to the debug I did, it seems to me that the instructions for the request are these:

System.Threading.Thread workingThread = new Thread(ScanWork);

I still can not figure out how I get the answer but I'll try to figure it out.

In the meantime I ask for your help once more.

Best regards,

Alberto Ferraz

  • The code you quote just runs a method named "ScanWork" in a separate thread. We have no way of knowing what that method does. What is your question?
  • Hi Michael,

    The method "Scanwork" is below (the parameters.TCP are TCP)

    /// <summary>
    /// Method is processing request based on parameters.
    /// </summary>
    /// <param name="o">Parameters from the input form.</param>
    public static void ScanWork(object o)
    //Thread can only have object as parameter so we need to cast it to our class
    if (!(o is ASInterfaceIntegration.DataManipulation.Parameters)) return;
    ASInterfaceIntegration.DataManipulation.Parameters parameters = o as ASInterfaceIntegration.DataManipulation.Parameters;

    if (parameters.TCP) // TCP request sent
    DoWork.ScanTCP(parameters.RequestXml, parameters.Hostname, parameters.Port, parameters.AdditionalPort);
    else // HTTP request sent
    if (parameters.EnableJson) // JSON
    // callback can contain any value
    DoWork.ScanHTTP("callback=Test", parameters.TargetURL, parameters.Action, true);
    else // XML
    DoWork.ScanHTTP(parameters.RequestXml, parameters.TargetURL, parameters.Action, false);

    My question is how do I do it?


  • Again, the most relevant code is not in this method, but in methods it invokes, which we can't see. (And pasting more source into posts would not be a very good way to show us.) The easiest way to accomplish what you want might simply be to build your sample C# code into an assembly with a suitable public interface, then invoke that from your COBOL code. Do you actually need it rewritten in COBOL?
  • Hi,

    The C # code I have is from a demo application that the vendor the scanner has sent me. The demonstration is great because it also includes the screens of parameterization, selection, etc.

    With the debug I made I "got" the instructions that are used to make the request but, as it refers, it is difficult to catch all the methods. The idea of ​​rewriting in cobol is because I have to integrate this process into an application.

    In terms of the manual I do not have much information either. I have only the request data and the information layout to receive.

    I'll try to see the vendor if I get a simpler program that has just the part that matters.

    Best regards

    Alberto Ferraz


  • If the vendor doesn't have a simpler example, could you attach the C# file with the relevant code to a post? That would be easier to work with than code pasted into the body of a post.
  • Hi again,
    While I have no response from the vendor attached attachment the program in C # which, I believe, has the main part of the code needed.

    The required parameters are:

    - RequestXml - XML ​​file that I send attached too

    - Hostname - ""

    - Port - "56702"

    - AdditionalPort - "0"


    The other programs are to "build" the xml that is sent in the request and to set the necessary parameters.

    I do not know if I can do something with what I send.

    Thanks again.

    Best regards,

    Alberto Ferraz
  • Well, there are some 600 lines of C# code there (and not particularly good code at that, in my humble opinion). When I have time I'll see about translating the relevant parts to managed COBOL, but I'm afraid that at the moment I have more pressing tasks that need my attention. I may be able to get to it later today, but it might have to wait for the weekend.
  • Hi,

    I believe that it is not easy to translate that because, as he says, there are many lines and options. Still, there are priority issues.

    Anyway, I'm checking to see if the supplier sends me what I asked for.

    If you happen to be able to look at the situation, thank you.

    Best regards,

    Alberto Ferraz

  • Hi,

    I received from the supplier this comment on what needs to be done.

    I do not know if it simplifies the question.

    1º - Open the TCP port locally on the computer (

    2º - Send the request to port 56702 (file request_default.xml atached)

    3º - Door is always open

    4º - The scanner work and create the response xml file

    5º - The XML result is returned in the same channel that is still open - file response_default.xml 

    6º - To finish, after sending the XML, the channel is closed


    Best regards,

    Alberto Ferraz

  • Hi again,

    I received from the vendor a smaller source and only with the instructions that need to be used.

    I believe that with this simpler source it will be possible to analyze and "convert" to Cobol.

    Attach the zip with the source (

    I also attached a zip.file with the scanner emulator ( It is an application that is installed and to which the program will fetch the data.

    I am waiting for your help again.

    Best Regards

    Alberto Ferraz