Hi Dan,
I think I understand your position; I also think you're asking a bigger question than you think you are... you say:
I spent a lot of time trying to do this simply with a vfp COM DLL and vbscript...
I just wish that it was possible to do this without having to run your own web server.
If you read my original post carefully, I am asking a very simple question: How to access VFP code through a browser.
I have NO interest in designing an entire website. just one form that submits very few parameters to a VFP class and gets something back from it.
Here's a more specific question: If I register a VFP DLL on the web server, can every client access it, or would they have to register the dll?
Here is how I managed to run VFP code in a browser WITHOUT using IIS/FOXISAPI/FOXWEB/WebConnect/AFP/ASP or any web server software....
This method reveals a fundamental lack of understanding of HTTP and web technologies. It is also similar to Microsoft's abandoned "ActiveForm" approach to web pages.
To directly answer your questions:
If I register a VFP DLL on the web server, can every client access it, or would they have to register the dll?
No, you can't access a .DLL file using the CREATEOBJECT(...) calling method unless that .DLL is registered on the computer running the CREATEOBJECT(...) command. There's no way around it: CREATEOBJECT(progid) causes windows to search it's local registry for "progid", and if it isn't found there, then it can't access the object's DLL.
Now, you might think "then I'll have to register the DLL on every client, and then it will work". The problems occuring with this reasoning are:
1) Now every client will have to Trust your DLL (which is fine for friends and coworkers, but is absolutely impossible for a public website)
2) Now, you will have to determine & implement a way to distribute the DLL to each user: you can't simply "access" a DLL across the internet (in an executing-code manner).. it has to be downloaded then registered (executed). This is fundamentally insecure, so there aren't any ways that will do it for you: you'll need to create an installer program with something like installshield (or a batch file calling REGSVR32, etc) that will be downloaded and run before your website works.
3) Now, when the DLL is adjusted, you'll have to find a way to re-deploy the DLL to all the clients.
4)
most importantly: as the DLL is executing, since it is executing on the client and not on the server, it won't have any more access to server resources than the client computer. You won't be able to "USE mytable" (because mytable.dbl is on the server, and you don't have drive-share access across the internet), you won't be able to "SELECT * FROM mytable" (same reason). You could use HTTP GET to access web pages from the server that contain data, and then HTTP POST to submit data to a form processer on the server... but that's the part you seem to be trying to create, rather than wanting to use a part that already can do that.
It comes down to this: if Executable code is going to be running on the server (and not on the client), then you
need to care about the web server.
On a static web site, as Mike pointed out, the web server sits and waits for HTTP GET requests (which look something like this:
[tt]GET /ip_image.php HTTP/1.0
Host: www.printmyip.com[/tt]
)
then the server responds with the requested page or file (which looks something like this:
[tt]HTTP/1.1 200 OK
Date: Fri, 19 Aug 2005 14:29:13 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Accept-Ranges: bytes
X-Powered-By: PHP/4.3.2
Connection: close
Transfer-Encoding: chunked
Content-Type: image/jpeg[/tt]
... followed by the image data, or HTML text )
To run code (VFP code, or any other code) on the server, you need to make the web server understand that when it gets a certain request (perhaps, when it gets a request for any page that has the last letters ".asp" or ".dll" or ".cfm" before a question mark... this is called an "HTTP GET form submission" ) that the web server should then locate that resource (ending in .asp or .dll or .cfm), and hand it the parameters that follow the question mark.
These "extensions" are quite arbitrary... you could define a new one ".VFP" that is VFP code (or .PRG). However, there are now standards that are pretty commonly followed:
.asp = Load the Active Server Pages .DLL and tell it to handle this page, and break the stuff following the "?" down into name-value pairs, and hand all these parameters to the asp .dll. This asp script may contain CREATEOBJECT commands that instantiates a VFP COM DLL and accesses a method on it, etc. Since the web server loaded the "Active Server Pages .DLL", the asp script is executing on the server, and therefore the VFP COM DLL will instantiate on the server, and have access to all the server's resources (dbf files, mapped drives, etc).
.cgi or .pl = Dump the stuff following "?" into a text file, then Load the perl command interpreter and hand it the name of the text file
.dll = Treat this file as a virtual directory: Use the ISAPI functions to load this DLL and hand it the stuff following the "/" as a single big parameter. Let the DLL do what it wants from there on.
Clearly, this last one is what is used for FOXISAPI.. the calling prototype for the URL is this:
To use this Foxisapi example, there are some things needed:
1) FOXISAPI.DLL must exist on the server in the folder identified by "/path/"
2) FOXWEB.DLL is a VFP dll built by you (FOXWEB.PJX is an example project provided with VFP by microsoft.. it's simplest to add classes to that project rather than start from scratch, so FOXWEB.DLL is what the dll often ends up called).
3) "MyClass" is a class in the FoxWeb project that is OLEPUBLIC
4) "MyMethod" is a method in MyClass, and takes these parameters:
PARAMETERS p1,p2,nPersistInstance
P1 might be filled with all the form fields and values in URL-encoded format (result of a HTTP-GET form submission)
P2 might be filled with the name of an .ini -format file containing the form fields and values (result of an HTTP-POST form submission)
nPersistInstance is an output parameter, and determines whether the DLL should be released by FOXISAPI.DLL after it is done with it.
This method should return a string containing the page to send to the web browser.
I hope this makes it a little clearer to you how a webserver interacts with executable programs.
- Bill
Get the best answers to your questions -- See FAQ481-4875.