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?
LVL 4
spk2000arAsked:
Who is Participating?
 
2266180Connect With a Mentor Commented:
2.1) it can be done but it's a little tricky. I think just passing sw-Hide as the showing parameter or what's its name shoudl do it (I don't have an IDE handy to check). if it doesn't, then you will have to use createprocess(ex?) and there you have alot more control over the process, including it's PID (which you will use to kill it with). using shellexecute will need you to dig through the windows to find the process which is a little dirty. so in this case, createprocess(ex?) is better
2.2) this idea would be even better the 2.1 because you will not have to kill that process in case you will need it to get many times that url (or other urls). so you keep it running in the background, use a sharedmemory to pass the data (the url) to it, and then that helper process will create a thread to deal with the url. indy should be sufficient since there is no active script/control to be executed.

note that background process does not mean system tray :) although you can have it sit in the system tray but that willd efinetly raise teh users question: what's that running in my system tray? :)
0
 
ziolkoCommented:
>>I need to call from desktop delphi application, an asp code that do some process in web server
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.
0
 
2266180Commented:
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 :)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
spk2000arAuthor Commented:
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?
0
 
2266180Commented:
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.
0
 
spk2000arAuthor Commented:
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?
0
 
spk2000arAuthor Commented:
Just for the record... 2.2 is what is running by now.
Using ShellExecute(handle, 'open', FullFileNameOfMyAppWithoutAnyFormsOrResource, 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.
   
begin
  MyidHTTP := TidHTTP.Create(nil);
//idHTTP of Indy 10
  MyidHTTP.Get(ParamStr(1));
//0 = FullFileNameOfMyAppWithoutAnyFormsOrResource
  MyidHTTP.Free;
end;

Open in new window

0
All Courses

From novice to tech pro — start learning today.