I used to do a little ISAPI program. I have been looking for a long time for a long time. I didn't write it all. After two months of exploration, I finally did something. For a long time, I always wanted to write an article about ISAPI, but I haven't had time, I have time to write a lot of time, I have written recently, I will return it. Slightly thinking, want to write the following: 1. ISAPI Description 2, a simple ISAPI program 3, ISAPI implementation client / server interaction 4, ISAPI Operation Database 5, using ISAPI for network data transmission 6, ISAPI transmission data encryption 7 , ISAPI network data transfer advancement (network big data package transfer) 8, summary
First, ISAPI Introduction
General Gateway Interface CommongatewayInterface (CGI) has been widely used as a standard for interactive web applications in the Internet. The CGI script allows people to write simple applications with multiple programming languages (such as Basic, C, Perl, Shell, etc.). These scripts are running on the web server and output running results on the customer's web browser. The customer's input is passed through an environment variable or a standard input device, and then the CGI program completes a specific operation as needed, and displayed in the customer's browser via HTML format. This feature of CGI brings a vitality to the Internet, and the construction of the website has also become a warm girl from the silence of the scene, and the Snow White, the Snow White, is also increasingly tired. People in long-term use still discover a large disadvantage of the CGI application: the performance is not high. Every time I request a CGE program, the CGI execution file (or script interpreter) must create a new process for each request. For sites that are relatively large, this is undoubted to add a heavy burden to the server. In the years, the lively Internet has introduced ASP, JSP and other measures to improve safety and server performance, and the maturity of the security and development tools is far less than the success of VC, Delphi, etc., and as a Familiar with software programmers, using ready-made development tools and existing resource development, a website system is more powerful.
ISAPI (Internet Server Aplication Programing Interfase) is developed with a programming tool, a standard programming interface that runs in NT services, and web developers can use it to write interactive applications. The ISAPI extension application has the same functionality of CGI scripts, but it has faster and more efficient than CGI. ISAPI for Windows NT written, web users can activate the application by filling in an HTML form (FORM) or click on the link on the HTML page on the Web node. After the server is acquired, the activated ISAPI application processes the obtained information. The data in accordance with the ISAPI application or stores the acquired information into the database, or to obtain data in the database, and then send the result in the form of the HTML page back to the client. Isapi's application is compiled as a dynamic link library (DLL, DYNAMIC Linked library), which is loaded in the WWW service (Service) starts in memory. It requires less system overhead, which is significantly better than CGI applications. Because each request does not start a separate process. For interactive procedures with CGI, each request needs to start a separate process.
Isapi has a significant performance advantage, but its debugging does not have fewer development materials, and has always become a cause of developers. In order to use iSAPI more widely, special as this article, for the majority of developers to enter the development process faster. return
Second, a simple ISAPI program
New, Object, isapi extension wizard, Object Name gives a firstisapi, ok, the second step is not changed, point FINSHED is complete. Press F7 to put the generated DLL in the C: / INETPUB / WWWROOT / FIRSAPI directory (don't use me to teach it?), Open your browser, enter http://127.0.0.1/firstisapi/firstisapi in the address bar .dllok We can see the following: this default message. If you see the above English characters, your server can be used. If you see a download file dialog, don't cry! Explain that your server is not configured, let's take a step by step, don't miss this opportunity! Start, program, management tool, Internet service manager, open the left tree, find the firstisapi under the default Web site, and the mouse is marked in the right button, the property, the execution license drop-down list, check the script and executable? Also don't move (if you think it is fun, you can do it, but the server configuration is not good. Don't blame me "declaration :)"). What do we have to do? Forgot, wait! Oh, right , Click OK, if not, you are Chinese version, then sure it! Ok, http://127.0.0.1/firstisapi/firstisapi.dll ------------- ---------- >>>
THIS Default Message Was Produced by The Internet Server DLL Wizard. Edit Your Cfirstisapiextension :: Default () Implementation To change It. This time I saw it? Already? Forget it, don't learn isapi, more trouble, you don't bother me I bother, stinking! (I think about it, this may still have, I still have a person, so that you can just yell, good, open the CD drive, put the 2000 disc, still ? Add a component, reload your Internet service! ...) Will n't you do it? No Chineseq608@163.com OICQ: 67406204http://www.ources.net Contact me, I will Help you !!! ~~~~~~~~~
So, our first ISAPI is made, you can do it, I will do isapi ........--------- fart! This is also called?
Yes, forgot Win98 friends, sorry, have you installed PWS? That pack! Other and 2000 Datong, don't use me? :) :)
return
Third, ISAPI implements customer / server interaction
We can now make a simple ISAPI program, but it doesn't have it, after all, we haven't added the code you move! In CFirstISAPIExtension class as the same general procedure was added to make a member function void Getdata (CHttpServerContext * pCtxt, char * data); then added ON_PARSE_COMMAND (Getdata, CFirstISAPIExtension, ITS_PSTR) between BEGIN_PARSE_MAP (CFirstISAPIExtension, CHttpServer) and END_PARSE_MAP (CFirstISAPIExtension) and ON_PARSE_COMMAND_PARAMS ( "data"), as follows: BEGIN_PARSE_MAP (CFirstISAPIExtension, CHttpServer) // TODO: insert your ON_PARSE_COMMAND () and // ON_PARSE_COMMAND_PARAMS () here to hook up your commands.// For example: ON_PARSE_COMMAND (Getdata, CFirstISAPIExtension, ITS_PSTR)
ON_PARSE_COMMAND_PARAMS ("DATA") ON_PARSE_COMMAND (Default, CfirstisapieXtension, ITS_EMPTY) DEFAULT_PARSE_COMMAND (Default, cfirstisapiextension) end_parse_map (cfirstisapiextension)
ON_PARSE_COMMAND_PARAMS is the parameter map macro, the first parameter of ON_PARSE_COMMAND getData is a function name to handle the event. The second parameter cfirstisapiextension is the application subclass with chttpserver as the parent class, the back parameters to pass the parameters of the getData function. List, they can be: ITS_EMPTY: No data; ITS_PSTR: String; ITS_I2: Short integer; ITS_I4: long integer; ITS_R4: Float floating point; ITS_R8: Double floating point number. The number of parameters is generally corresponding to the parameters parsing the following on_PARSE_COMMAND_PARAMS. We can assign an initial value here when we don't pass the actual values of this parameter in your browser. Such as Data = www.orcode.net; here DATA is the parameter name we have to get in the getData.
With these preparations, we can add code, because it doesn't have something in peaceful programming, so we will simply add a little code to see what we have done for a long time?
as follows:
Void cfirstisapiextension :: getData (chttpserverContext * PCTXT, CHAR * DATA) {
STARTCONTENT (PCTXT); // Write HTML file headwritTitle (PCTXT); // Write title * PCTXT << _t ("This is the data you submitted:
/ r / n"); // To browser Send data * PCTXT << Data << "/ r / n"; // Write a wrap and carriage return ENDCONTENT (PCTXT)
}
ChttpServerContext * PCTXT is a server context sign, we transfer data to your browser. * PCTXT << The string after the browser is the HTML source in the browser, so you can put "this is the data you submitted:
/ r / n "changed to HTML you want, I want to change you! :) Is it going to press F7? Haha, good, f7, immediately put firstisapi.dll ctrl c, ctrl v ........
"Unable to create or replace Firstisapi: The specified file is being used by Windows, can not be?
I will restart computers, who teaches it to load memory! However, you change the DLL to change your name, you have to wait for a smoking company!
The article ISAPI debugging, you can take a look at friends who don't love the old computer. ISAPI is part of IIS at runtime, while IIS is run as a service of NT. This fact has become more complicated using the debugging process, because when the IIS is running, the VC debugger cannot take over ISA. In order to solve this problem, Microsoft has issued IIS in two forms: as a service, as well as a separate executable. For the latter case, we can control the server on the command line. Although this can solve the above problems and make it easy to develop, it is very cumbersome. Let's introduce this process.
When the user is in debug debug mode, VC (and IIS) will run under the user's account and permission. Since some of the works completed in IIS are not allowed to have corresponding permissions, the user (or user system administrator) needs to do the following:
Select "Start / Program / Manage Tools (Public) / Domain User Manager" on the desktop, open the domain user manager; select "User Permissions" in the Rules menu; select "Show Advanced User Permissions" check box; Select "Operation System Mode Operation" in the "Permissions" drop-down list; select the "Add" button to get the Add User and Group dialog box, select the "Show User" button and select the user who uses the user in the "Name" list. Then select the Add button; select the "OK" button; repeat the above steps for the "Generation Security Audit" permission.
In order to take these settings, users must first quit login, and then log in back. The IIS contains three services: ftppublishing service, GopherpublishingService and WorldWideWeb. Since the debugger wants to run IIS on the command line, all three services must be stopped. This can be implemented in the "Services" program in the Control Panel or use IIS's "Internet Service Manager". If you need a lot of debugging, we recommend that users shut down the IIS service through the "Service" program in Control Panel, and prohibit them from starting, so that users should be turned off each time the computer is turned off. Next, the project must be configured: Select the settings menu item in the Project menu; select the debug panel, and select General in the Category drop-down list; enter or find the path to the IIS execution file in the ExecutableFordebugSession box (usually in the case Winnt / System32 / INETSRV / INETINFO.EXE); Enter -EW3SVC in the ProgramArguments box, as shown in Figure 3; Figure 3 Debug panel settings Select the LINK panel; enter the path to the compiled DLL in the OutputFileName box and file name. This path must be in the root directory of the web server or under a virtual target so that the customer can access it through the URL. For example, our directory of our web server is C: / INETPUB / WWWWROOT / FIRSAPI, we put firstisapi.dll in this directory so that customers can use the following URL to access it: http: //127.0.0.1/firstisapi /firstisapi.dll If the user has not exited login to change the permissions, please act now, and then log in back. In this way, our server DLL is very successful, hurry up in the browser http://127.0.0.1/firstisapi/firstisapi.dll?getdata&data= this is the information I sent to the server! OK?
This is the data you have submitted:
This is the information I sent to the server!
OK!
Do we want to submit data to the server in form form?
The following HTML source code is stored as a firstisapi.htm file and placed in the same directory in the DLL.