0

I am having a requirement to check the feasibility of being able to call ESQL/C programs directly from java. These ESQL applications are deployed in Linux and can be spawned multiple instances.

Currently they are being called from .NET via Camel application which finds the port and makes call via XML using Soap.

While searching I got few links to call Java from ESQL/C but couldn't find any for vice versa. Has anyone tried to call ESQL/C from Java?

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:ns="http://tempuri.org/ns.xsd">
    <SOAP-ENV:Body>
        <ns:gatewayValidate>
            <in>
                <serverId>tpmDss</serverId>
                <Request>getData&#x1F;&#x1E;101&#x1F;def&#x1F;1&#x1F;5660&#x1F;3001&#x1F;1&#x1F;</Request>
            </in>
        </ns:gatewayValidate>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here serverId contains the name of the application which would be called with the payload in Request.

I am aware about JNI for calling C++ DLL's but I am afraid I don't have control to edit these legacy ESQL/C programs.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
djyo02
  • 27
  • 1
  • 11
  • Please define the term 'ESQL'. Are you talking about the domain-specific language used by IBM Integration Bus? Or something else? – kimbert May 04 '20 at 15:41
  • yes, it is esql/c programming language. It uses C variable types and if/for loops to prepare the sql query and execute them. I am looking for how to hit these programs from java and get a response. – djyo02 May 04 '20 at 16:06
  • When you say "call an ESQL/C application", do you mean "have Java execute a C program (that happens to have used ESQL/C as part of the process of generating the executable)", or do you mean "call a C function from within ESQL/C application directly from Java". If you mean the former, it is as doable as running any other C program from Java — though you might have more work to do to ensure the environment is correct for the ESQL/C code. If you mean the latter, then it isn't doable, any more than you can call a function that happens to be part of the shell (the shell being another C program). – Jonathan Leffler May 04 '20 at 21:55
  • @JonathanLeffler - I believe it is the latter part. ESQL/C has the code which needs to be called from Java. The Soap payload that I have shared it being used to interact with this ESQL/C program. I want to know does ESQL/C programs can accept HTTP requests because if they can I can look at creating REST API's to interact with them. Although I am aware of the environment issues which I need to take care as the ESQL/C programs don't have the fixed port as java programs. I have plans to use TOMEE ESB to check the port and send request to at run time. – djyo02 May 05 '20 at 06:00
  • You said "ESQL/C application" — I take that to mean an executable, not something built into a library. If it is in a library, you should be able to use JNI or something similar to run the functions. If they are full executables, you won't be able to have Java invoke functions found within those executables. You will have to run the programs, providing the appropriate input that they expect and interpreting the output they produce. – Jonathan Leffler May 05 '20 at 06:44
  • @JonathanLeffler - Yeah these are full executables. What do you mean by programs? In which language do these programs need to be written? The above snapshot is the sample input expected by the executable. Can you please provide some direction so that I do some POC around that? – djyo02 May 05 '20 at 08:40
  • In my terminology, programs and executables are synonymous. An application might be a single program or executable, or it might be a suite of them. – Jonathan Leffler May 05 '20 at 13:42
  • @JonathanLeffler - As you mentioned - "You will have to run the programs, providing the appropriate input that they expect and interpreting the output they produce." so I had a doubt whether this program can be written in java which then directly talks to esql/c program or it needs some other framework in between to act as mediator between java and esql/c. – djyo02 May 05 '20 at 14:11
  • You finally need someone who knows enough about Java to help you. To the extent I've provided any help, it has been via generalities, not the details of Java. I expect you can use Java to send data to an ESQL/C program via pipes or files and retrieve the results. I have no clues about how you go about doing that — what there is built into the Java runtime libraries, or readily available as Java extension libraries. I'd be suggesting you used `popen()` and `pclose()` if this was C; whether that helps with Java or not, I don't know (probably not). – Jonathan Leffler May 05 '20 at 14:26
  • @JonathanLeffler - I can take care of Java part. Does ESQL/C accepts HTTP or it works on TCP only? I am sure that it doesn't accept JSON. I need info on how to make communication with ESQL/C programs? – djyo02 May 06 '20 at 09:55
  • Whether an ESQL/C program accepts HTTP depends on whether the program is written to do do. ESQL/C is tangential to HTTP. It is not certain the program will know what TCP is; that too depends on how the program is written. An ESQL/C program talks to a database (presumably) but is otherwise a program that does its task. It could be a GUI program. It could be a command line program. It could be some sort of web server. It depends on what it was written to do. – Jonathan Leffler May 06 '20 at 17:34
  • @JonathanLeffler - I checked the ESQL/C program and it is not having JNI export so that option is now ruled out. I will see try to see some other way of interacting with esql/c program. Thanks for sharing many insights on ESQL/C. It was a lot of help!! – djyo02 May 11 '20 at 09:02

0 Answers0