Board index » delphi » How to send data from ISAPI to exe application and get back result

How to send data from ISAPI to exe application and get back result


2008-03-04 03:09:07 AM
delphi179
Hi,
I have ISAPI and one Action let's say Upload. I need to send Request.Content
data
to my exe(application) for uploaded data manipulation and send result back
from exe to ISAPI
and display that data for user. What is the best way to comunicate between
application?
I would like to note that Request.Content will be prety large about 10mb, it
will contain form data and file.
example
procedure Twm.wmUpload(Sender: TObject; Request: TWebRequest; Response:
TWebResponse; var Handled: Boolean);
begin
SendToExe(Request.content)
//waiting for response from exe
Response.content(GetDataFromExe)
end;
Regards,
Tomas
 
 

Re:How to send data from ISAPI to exe application and get back result

The only way to do that is do it in a thread. If the thread hangs (called
program doesn't complete) then the thread has to timeout, if the system is
running slow, or communication is slow, the thread can be fooled into
thinking it is taking too long and then it times out only to have the exe
call it back 1 ms later but the isapi will no longer be listening.
In one action item in an ISAPI you can upload the data, process it , and
return a response to the user smoothly.10 MB is not a lot of data.
 

Re:How to send data from ISAPI to exe application and get back result

"Del Murray" <XXXX@XXXXX.COM>writes
Quote
The only way to do that is do it in a thread. If the thread hangs (called
program doesn't complete) then the thread has to timeout, if the system is
running slow, or communication is slow, the thread can be fooled into
thinking it is taking too long and then it times out only to have the exe
call it back 1 ms later but the isapi will no longer be listening.
Do you know any solution how to send/receive data to/from exe?
Quote
In one action item in an ISAPI you can upload the data, process it , and
return a response to the user smoothly.10 MB is not a lot of data.
Unfortunatelly I can't, I need to submit to our application for data
processing.
 

Re:How to send data from ISAPI to exe application and get back result

Quote
Unfortunatelly I can't, I need to submit to our application for data
processing.
We use something shown on this site which works for command line
applications:
www.delphi-treff.de/tipps/system/tipp/524/
to start an external application, send and receive data from and to it.
(we need to do this since it is a third party analyzer module and has
quite bad memory management).
This site is in german but the code will speek for itself.
kind regards
Mike
 

Re:How to send data from ISAPI to exe application and get back result

One way is to use the Indy components in both the ISAPI and the EXE.
HTTP Servers will allow communications between the web and exe modules. The
Indy components are "blocking"., You can send a request to a server and then
listen for a response telling it is done. When the response returns , then
the listener can pass a response back to the web user who started the
process. In this mode, you better hope the exe finishes properly and
responds to message from ISAPI or ISAPI will just pause forever.
Look at IDHTTPServer to send http messages between applications.
Another way is use some exterenal control method. ..
Isapi accepts uploaded file and writes it to DB or flat file with a "control
record" in a DB.
Exe sees the control record appear and processes the data.
Exe updates control record signalling he is done.
Meanwhile, ISapi, after writing control record, starts checking control
record with reads to db. These should have "pauses" in them of some kind ..
perhaps use a thread where the wait is done.
You could us a combo of both with http messages to carry this off.