Martin Barreda
asked on
Calling asp code from desktop application
Hi,
I need to call from desktop delphi application, an asp code that do some process in web server.
The idea is this. I do some process locally in desktop PC, exporting data to a ftp site. When this is finished, then i need to call an asp applet (something like this: www.anysite.com\someprocess.asp) that work with the exported data.
Asp should run in an "invisible" navigator window or something like that, to prevent user to close that window, or app lose focus, until the process is fully terminated, then that window should be closed.
During the web processing, desktop application must continue normally... the user do not have to notice that the asp page is working in background.
I have this enviroment:
- Delphi 7
- Indy 10
Is this can be done?
I need to call from desktop delphi application, an asp code that do some process in web server.
The idea is this. I do some process locally in desktop PC, exporting data to a ftp site. When this is finished, then i need to call an asp applet (something like this: www.anysite.com\someprocess.asp) that work with the exported data.
Asp should run in an "invisible" navigator window or something like that, to prevent user to close that window, or app lose focus, until the process is fully terminated, then that window should be closed.
During the web processing, desktop application must continue normally... the user do not have to notice that the asp page is working in background.
I have this enviroment:
- Delphi 7
- Indy 10
Is this can be done?
in case there is no need for a twebbrowser (like that page does not contain java script or an activex control or otehr stuff that need to be executed locally on the client) it is sufficient to just call:
idhttp1.get('http://www.anysite.com/someprocess.asp');
(since you mentioned indy)
this will be less resource consuming for your app then using a twebbrowser :)
idhttp1.get('http://www.anysite.com/someprocess.asp');
(since you mentioned indy)
this will be less resource consuming for your app then using a twebbrowser :)
ASKER
I like more Ciuly's answer but... the form from where i make the call will be probably be closed just before the call was make... possible all application should be close, but i need someprocess still be executing until it ends.
someprocess.asp takes (lets say), 3 minutes to finished its work. It do not have activeX or any visible control. It is just a blind process that takes data in an MDB database and make individual semistatic pages.
Locally... the user do not have to notice that this is happening.
I really do not know, but i think that if browser window, or something like that, is closed before it finished, the process will not ends right... is that right?
someprocess.asp takes (lets say), 3 minutes to finished its work. It do not have activeX or any visible control. It is just a blind process that takes data in an MDB database and make individual semistatic pages.
Locally... the user do not have to notice that this is happening.
I really do not know, but i think that if browser window, or something like that, is closed before it finished, the process will not ends right... is that right?
actually no. the minute the browser window closes so does it's connection which will signal the webserver that the client closed which will signal teh appropriate payers about it thus leading to a dead end.
there are several solutions to this problem (consdiering that the processing you mention takes 3 minutes or more):
- if the program itself is not closed (only some form, and the program continues to run either in the background or having the main form visible), then you can use a thread to make the idhttp1.get call
- if the program does close, you have 2 options:
-- 1) don't close the program until the processing is finished (hide the forms and all that. but the user will still see the process in task manager IF he bothers to look there :) )
-- 2) create another process (shellexecute for example) which will run in the background, no forms, no nothing and will do the get call
- and finally, you could solve this on the server side by responding to the get with nothing (or bogus) and keeping the process on the server still running.
for example, you have a method somewhere which will start that lengthy process. don't do it right there, but instead start a new thread which will do that processing.
but I am afraid that further details on how to solve this server side depends alot on what and how you are doing things server side.
in my opinion, this matter should be solved server side, as it is a server side processing which the client is not interested about so there is no sense in making it wait for it. so teh idhttp1.get will finish in a split of a second, while the server wil continue doing whatever it needs to do.
there are several solutions to this problem (consdiering that the processing you mention takes 3 minutes or more):
- if the program itself is not closed (only some form, and the program continues to run either in the background or having the main form visible), then you can use a thread to make the idhttp1.get call
- if the program does close, you have 2 options:
-- 1) don't close the program until the processing is finished (hide the forms and all that. but the user will still see the process in task manager IF he bothers to look there :) )
-- 2) create another process (shellexecute for example) which will run in the background, no forms, no nothing and will do the get call
- and finally, you could solve this on the server side by responding to the get with nothing (or bogus) and keeping the process on the server still running.
for example, you have a method somewhere which will start that lengthy process. don't do it right there, but instead start a new thread which will do that processing.
but I am afraid that further details on how to solve this server side depends alot on what and how you are doing things server side.
in my opinion, this matter should be solved server side, as it is a server side processing which the client is not interested about so there is no sense in making it wait for it. so teh idhttp1.get will finish in a split of a second, while the server wil continue doing whatever it needs to do.
ASKER
Thinking on the 2 options that Ciuly offer...:
1) the alternative is passed to asp developer (other that me), and i am waiting for an answer. It seems the best choice... make the server do the work.
2) but if this can't be done (or if he don't want... :) ), there is my formerly idea... use shellexecute to call the default browser (firefox, opera, ie) or a minibrowser made by me to exec the process.
2.1) using the default browser, i have this problem, how can i make the open windows not visible, and then have the hiding process kill without user intervention. So that is my original question.
2.2) or, here is something new... i make a minibrowser... a form with some asp component?, that runs in system tray until it closes... or should i use only indy http get in that form as you say before?
1) the alternative is passed to asp developer (other that me), and i am waiting for an answer. It seems the best choice... make the server do the work.
2) but if this can't be done (or if he don't want... :) ), there is my formerly idea... use shellexecute to call the default browser (firefox, opera, ie) or a minibrowser made by me to exec the process.
2.1) using the default browser, i have this problem, how can i make the open windows not visible, and then have the hiding process kill without user intervention. So that is my original question.
2.2) or, here is something new... i make a minibrowser... a form with some asp component?, that runs in system tray until it closes... or should i use only indy http get in that form as you say before?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just for the record... 2.2 is what is running by now.
Using ShellExecute(handle, 'open', FullFileNameOfMyAppWithout AnyFormsOr Resource, DirOfASPCode, nil, SW_SHOWNA).
The application, just did something like this (i do not have it by hand now)... in app source code, and no more.
Using ShellExecute(handle, 'open', FullFileNameOfMyAppWithout
The application, just did something like this (i do not have it by hand now)... in app source code, and no more.
begin
MyidHTTP := TidHTTP.Create(nil);
//idHTTP of Indy 10
MyidHTTP.Get(ParamStr(1));
//0 = FullFileNameOfMyAppWithoutAnyFormsOrResource
MyidHTTP.Free;
end;
you mean you have .asp file locally on your disk and want run it in Delphi? if so then it's not possible
if you want to call www.somesite.com\someprocess.asp just like you do with webbrowser then place TWebBrowser on your form and use WebBrowser1.Navigate('www.somesite.com\someprocess.asp');
ziolko.