JDJVR
asked on
Submitting Variables from a Delphi EXE to a Web Page
Hello
Looking for the easiest way to submit a variable generated from within a Delphi application (standalone exe) to a web page, where it is processed by an ISAPI dll, and the processed value returned to the application. Done a lot of Delhi development, but not much in the way of web programming. Can anyone help?
JDJVR
Looking for the easiest way to submit a variable generated from within a Delphi application (standalone exe) to a web page, where it is processed by an ISAPI dll, and the processed value returned to the application. Done a lot of Delhi development, but not much in the way of web programming. Can anyone help?
JDJVR
Is the ISAPI expecting a GET or a POST?
Do you already have a web page that does this action?
ASKER
Hi Eddie
I have to design everything from scratch - a portion of the exe, ISAPI, and web page. The whole thing boils down to the following process:
1. I click a button in the exe and this opens a web page on which a Web app (dll) resides. An integer variable is submitted from the exe to the web page to be used by the dll.
2. The dll uses the variable to calculate a return value. (also integer)
3. This return value is passed back to the exe and displayed in a text box on the exe GUI.
I know this is almost like requesting a tutorial, but the Delphi documentation do not offer much in the way of examples (is this an understatement??) and I need to have a clear understanding of the principles involved before diving in and making a hash of it. Since the architecture of the ISAPI is not cast in stone yet, I am open to suggestion as to the best way to proceed.
Thanks
JDJVR
I have to design everything from scratch - a portion of the exe, ISAPI, and web page. The whole thing boils down to the following process:
1. I click a button in the exe and this opens a web page on which a Web app (dll) resides. An integer variable is submitted from the exe to the web page to be used by the dll.
2. The dll uses the variable to calculate a return value. (also integer)
3. This return value is passed back to the exe and displayed in a text box on the exe GUI.
I know this is almost like requesting a tutorial, but the Delphi documentation do not offer much in the way of examples (is this an understatement??) and I need to have a clear understanding of the principles involved before diving in and making a hash of it. Since the architecture of the ISAPI is not cast in stone yet, I am open to suggestion as to the best way to proceed.
Thanks
JDJVR
the most simple way will be creating a url that contains your data and connecting it.
http://my.server.com/test.cgi?name=jdjvr&points=125&topic=delphi
your isapi dll will receive following parameters from this GET request
name=jdjvr
points=125
topic=delphi
then your isapi generates a response page and your delphi application can parse it.
a more advanced (read elegant) way is using XML as a data format for both request and response, for more information take a look at
http://delphi.about.com/od/webservices/
http://my.server.com/test.cgi?name=jdjvr&points=125&topic=delphi
your isapi dll will receive following parameters from this GET request
name=jdjvr
points=125
topic=delphi
then your isapi generates a response page and your delphi application can parse it.
a more advanced (read elegant) way is using XML as a data format for both request and response, for more information take a look at
http://delphi.about.com/od/webservices/
Are you against using something like PHP instead of ISAPI? PHP is very easy to use and learn and very easy
to setup on your web server or find a host that provides it.
I use PHP on a site that I maintain for a local baseball league and can use a Delphi to update the scores in
a mySQL database using idHTTP from Indy.
Without having something to test against, you may be grasping at straws. I agree with alikoank that you submit
the values either in a GET request, where the values you want to pass are in the URL, or in a POST where the
values will be sent via PostVars.
I posted a sample of how to post data to an asp page and get a return value here:
http://www.delphipages.com/threads/thread.cfm?ID=97550&G=97434
If you want more info on how to do the PHP end of things, feel free to contact me again.
to setup on your web server or find a host that provides it.
I use PHP on a site that I maintain for a local baseball league and can use a Delphi to update the scores in
a mySQL database using idHTTP from Indy.
Without having something to test against, you may be grasping at straws. I agree with alikoank that you submit
the values either in a GET request, where the values you want to pass are in the URL, or in a POST where the
values will be sent via PostVars.
I posted a sample of how to post data to an asp page and get a return value here:
http://www.delphipages.com/threads/thread.cfm?ID=97550&G=97434
If you want more info on how to do the PHP end of things, feel free to contact me again.
ASKER
Hi Eddie & alikoank
Thanks for the responses. It seems that GET and POST as described by alikoank will do the trick - the required function to be fulfilled by the dll is not very complex. Of PHP I know the proverbial zero - could you direct me to a GOOD reference site for more info?
JDJVR
Thanks for the responses. It seems that GET and POST as described by alikoank will do the trick - the required function to be fulfilled by the dll is not very complex. Of PHP I know the proverbial zero - could you direct me to a GOOD reference site for more info?
JDJVR
http://www.phpbuilder.com is one that I frequent. PHP isn't very difficult, especially if you know Java or C.
If you only know Delphi, it is a little more difficult to grasp some of the concepts.
What exactly do you want to do to these variables and what do you want to return?
If you only know Delphi, it is a little more difficult to grasp some of the concepts.
What exactly do you want to do to these variables and what do you want to return?
ASKER
Basically what the EXE does is to present the web page with an integer code generated from a variety of computer hardware and software serial numbers, which is then reworked and converted into an encrypted integer code and passed back to the EXE. This unlocks certain functionality on the EXE. (converting the program from a demo to fullly functional version). I am not fluent in either Java or C, but did some extensive study of HTML, XHTML and XML to get acquainted with web page architecture a couple of weeks ago. Must say I found those quite easy - also had a quick look at some Java scripts which did not appear totally confusing.
My main concern at this point is just to get the job done as quickly as possible - a value must be passed from the EXE to the web page, and another back to the EXE, preferably within the framework of my knowledge of Delphi and HTML. By the way, the web page will be hosted on a computer running some flavour of Unix - so my dll will be developed cross-platform and compiled in Kylix.
My main concern at this point is just to get the job done as quickly as possible - a value must be passed from the EXE to the web page, and another back to the EXE, preferably within the framework of my knowledge of Delphi and HTML. By the way, the web page will be hosted on a computer running some flavour of Unix - so my dll will be developed cross-platform and compiled in Kylix.
Why go to the trouble of building the ISAPI when you can have PHP running in < 1 hr.
If you give me some sort of idea how to manipulate the data, including some sample
input and what you are expecting as output, I could probably write something up in PHP
fairly quickly. Then I could show you how to pass this info from the Delphi EXE to the PHP
script and get the result back into the EXE.
If you give me some sort of idea how to manipulate the data, including some sample
input and what you are expecting as output, I could probably write something up in PHP
fairly quickly. Then I could show you how to pass this info from the Delphi EXE to the PHP
script and get the result back into the EXE.
I'll even place a copy of the script on my site so you can test it before installing it on your site.
ASKER
Hi Eddie
For the purposes of illustration, let us keep the number crunching simple. Let's say the EXE outputs a 6-digit value 654321 and assigns it to a global integer variable idNum in the EXE. This value is passed to the web page, where it is converted into a string variable, idStr. The string is then dissected into single digits, each of which is again changed into integer, and multiplied with its position in the string, and added up. (I.e. 6x1 + 5x2 + 4x3 + 3x4 + 2x5 + 1x6) This total is added to the original idNum value and returned to the exe to be displayed in an Edit box, say EditCode. That's it. I should be able to follow the logic.
Thanks for your patience.
For the purposes of illustration, let us keep the number crunching simple. Let's say the EXE outputs a 6-digit value 654321 and assigns it to a global integer variable idNum in the EXE. This value is passed to the web page, where it is converted into a string variable, idStr. The string is then dissected into single digits, each of which is again changed into integer, and multiplied with its position in the string, and added up. (I.e. 6x1 + 5x2 + 4x3 + 3x4 + 2x5 + 1x6) This total is added to the original idNum value and returned to the exe to be displayed in an Edit box, say EditCode. That's it. I should be able to follow the logic.
Thanks for your patience.
Very simple, I'll have it to you shortly.
dump a Twebrowser on the form make it hidden, then point it to the DLL with the varibles in the URL
WebBrowser1.Navigate('www.mysite.com/cgi-bin/my.dll?var1=2&var2=3');
you can then read the source returned using this code
https://www.experts-exchange.com/questions/21073169/Getting-HTML-source-from-TwebBrowser.html
David
WebBrowser1.Navigate('www.mysite.com/cgi-bin/my.dll?var1=2&var2=3');
you can then read the source returned using this code
https://www.experts-exchange.com/questions/21073169/Getting-HTML-source-from-TwebBrowser.html
David
Ok, In your example the result would be 654377, correct?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Change the URL in the idHTTP.Get to wherever you place the PHP code.
You can use localhost for testing. If you have XP/2K, you can just install it
in the \Inetpub\wwwroot directory and test locally.
Be sure to install PHP first, however. You can download it from
http://www.php.net
Any more questions, let me know.
You can use localhost for testing. If you have XP/2K, you can just install it
in the \Inetpub\wwwroot directory and test locally.
Be sure to install PHP first, however. You can download it from
http://www.php.net
Any more questions, let me know.
ASKER
Thanks everyone, especially EddieShipman. Think I can take it from here. Got myself a fat PHP book and I'm halfway through it already - you were right, PHP is easy.
Regards
JDJVR
Regards
JDJVR
If you can tell me what you are sending and what you expect as a return value, I can whip
something up for you very quickly.