xmlHTTP technical data
xmlHTTP technology:
I. database remote management technology
an important link in the modern application of wide area network based on Internet is the remote monitoring of database. First of all, a brief review of the development process and mode of database remote management technology on the Internet:
early database remote management by writing CGI-BIN program module. However, the running speed of CGI-BIN is slow and the maintenance is very inconvenient, so it has been basically abandoned now.
there are many applications using component object model (Component Object Model, COM) in recent years, and the effect is also very good. However, if you are using a third-party server (the author's website is based on a third-party virtual host), the server often does not allow users to register their own components for confidentiality or other commercial reasons.
in recent years, the. Net platform launched by Microsoft and the J2EE platform of SUN are very high-end database remote management and service platforms. Can provide high-quality multi-layer (n-Tier) application services.
among them, .NET 's simple object access Protocol (Simple Object Access Protocol, SOAP) using Hypertext transfer Protocol (Hypertext Transfer Protocol, HTTP) and Extensible markup language (Extensible Markup Language, XML) technology to achieve cross-system (such as Windows-Linux) communication service has been widely accepted and used by developers. Many large-scale applications, such as enterprise resource planning (Enterprise resource planning, ERP), are built on such a large platform.
but for small and medium-sized applications, such as the construction and maintenance of a website, such a large application platform appears to be a bit too big and too expensive.
Microsoft, which once lagged behind in Internet technology and Java technology, took the lead in XML application development. The XMLHTTP protocol in her XML parser (MSXML) is a very convenient and practical client/service communication channel. With the comprehensive use of XMLHTTP and ActiveX data objects (ActiveX Data Objects, ADO/ADOX), the remote management of database can be realized easily.
this article introduces how to comprehensively use XMLHTTP and ADO/ADOX for remote database management.
II. Database remote management system
the task flow of remote database management is:
1, the client sends the query or modification instructions of the database structure and data to the server.
2. The server accepts and executes the instructions and returns the results to the client.
3. The client accepts and displays the execution result of the instruction returned by the server.
the two key links to realize remote database management are
1, and the data channel for uploading instructions and downloading results between the client and the server, which is implemented by XMLHTTP protocol.
2. The instruction transmission and result return between the server front and the database are completed by the ADO/ADOX interface which acts as the middle layer.
III. Use of XMLHTTP
as the name implies, XMLHTTP is a hypertext transfer protocol for transmitting data in XML format.
in fact, XMLHTTP's data transfer process is more flexible:
its instructions can be XML format data, a string, a stream, or an array of unsigned integers. It can also be a parameter to URL.
the result can be XML format data, a string, a stream, or an array of unsigned integers. For more information on
, please see the link at the end of the article.
the process for the client to call XMLHTTP is very simple, with only five steps:
1, creating a XMLHTTP object
2, opening a connection with the server, and defining the instruction sending method, the service web page (URL) and the request permission.
the client opens a connection to the service web page of the server through the Open command. As with normal HTTP instruction delivery, you can use the "GET" method or the "POST" method to point to the service web page on the server side.
3. Send instructions.
4. Wait for and receive the processing result returned by the server.
5. Release XMLHTTP object
XMLHTTP method:
Open bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword
bstrMethod: data transfer method, that is, GET or POST.
bstrUrl: the URL of the service web page.
varAsync: whether to execute synchronously. The default is True, which means synchronous execution, but synchronous execution can only be implemented in DOM.
applications generally set it to False, that is, asynchronous execution.
bstrUser: user name, which can be omitted.
bstrPassword: user password, which can be omitted.
Send varBody
varBody: instruction set. It can be data in XML format, a string, a stream, or an array of unsigned integers. You can also omit it and let the instruction be substituted through the URL parameter of the Open method.
setRequestHeader bstrHeader, bstrValue
bstrHeader:HTTP header (header)
bstrValue:HTTP header (header)
if the Open method is defined as POST, you can define form upload:
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
XMLHTTP attribute:
onreadystatechange: get the event handle that returns the result in synchronous execution mode. Can only be called in DOM.
responseBody: the result is returned as an array of unsigned integers.
responseStream: the result is returned as an IStream stream.
responseText: the result is returned as a string.
responseXML: the result is returned as data in XML format.
the following is an example of an application in the source program attached to this article:
Function GetResult (urlStr)Dim xmlHttpDim retStrSet xmlHttp = CreateObject (& quot;Msxml2.XMLHTTP") 'create objectOn Error Resume Next 'error handlingXmlHttp.Open & quot;POST", urlStr, False 'opens the connection in POST mode and executes asynchronously.XmlHttp.setRequestHeader & quot;Content-Type", & quot;application/x-www-form-urlencoded" 'upload formXmlHttp.Send 'send instructionIf Err.Number = 0 Then'if the connection is correctRetStr = xmlHttp.responseText 'wait and get the result string returned by the serverElseRetStr = & quot;Url not found" 'otherwise an error message is returnedEnd IfSet xmlHttp = nothing 'release objectGetResult = retStr 'returns the resultEnd FunctionThe
GetResult () function takes the URL parameter of a service web page and places the upload instruction on the parameter after URL, such as:
urlStr = "server.asp?cmd=" & cmd & "& db=" & db & "table=" & table
cmd: execution mode, such as query, modification, deletion, and so on.
db: server database name
table: server table name
then submit instructions, wait and receive the returned processing results. The result is returned as a string.
the result is finally processed by the function caller and displayed.
--
Blog from: kingwkb
Copyright Protection: ShuDudu from the original article, reproduced Please keep the link: https://www.shududu.com/life/xmlHTTP-technical-data.htm