Introduction to Microsoft’s XMLHTTP Objects


Microsoft. XML HTTP object is provided in MSXML, which can complete the transformation and sending task from data package to Request object.
The statement for creating an XMLHTTP object is as follows:

Set objXML = CreateObject (“Msxml2. XMLHTTP”) or
Set objXML = CreateObject(“Microsoft.XMLHTTP”)
‘Or for version 3.0 of XMLHTTP, use:
‘Set objXML = Server. CreateObject (“MSXML2. Server XMLHTTP”) http-method,url,async,userID,password
The Open method contains five parameters, the first three are necessary, and the last two are optional (in theThe serverProvide when authentication is required. The meaning of the parameter is as follows:
http-method:HTTP communication, such as GET or POST
url:Receiving XML dataThe serverThe URL address. Usually ASP or CGI programs are specified in the URL
async:A Boolean identifier that indicates whether the request is asynchronous. If it is asynchronous communication (true), the client does not waitThe serverResponse; if it’s false, the client has to waitThe serverDo not perform other operations until the message is returned
userID:User ID forThe serverIdentity verification
password:User password, forThe serverIdentity verification
Send Method for XML HTTP Objects
After initializing Request object with Open method, Send method is called to send XML data:
ObjXML. send ()
There are two ways to send data: synchronous and asynchronous. In asynchronous mode, once the packet is sent, the Send process is terminated, and the client performs other operations; in synchronous mode, the client waits.The serverThe Send process is terminated only after the confirmation message is returned.
ReadyState attribute in XMLHTTP object
It can reflectThe serverProgress in processing requests. Client programs can set up corresponding event handling methods based on this state information. Attribute values and their implications are shown in the following table:

Response object has been created, but the process of uploading XML documents is not over yet
1. The XML document has been loaded.
2. The XML document has been loaded and is being processed.
3. Some XML documents have been parsed
4. The document has been parsed and the client can accept the return message.
The client processes the response information. After receiving the return message, the client simply processes it and basically completes an interaction cycle between C/S.
The client receives the response through the attributes of the XMLHTTP object:
responseText:The return message is treated as a text string.
responseBody:Return message as HTML document content;
responseXML:Consider the return message as an XML document, inThe serverUse when the response message contains XML data;
responseStream:Consider the return message as a Stream object
Here’s a simple example: news thieves
Set objXML = Server.CreateObject(“MSXML2.ServerXMLHTTP”) “GET”,””,false
% >

Recommended Today

Crash tracking journey of IOS development (I)

Preface: Recently, I encountered a crash blood disaster caused by crash in daily development. In a release in early May, the crash rate of the app developed by the author was directly increased from one thousand to nearly two thousand. At that time, the project leader just needed to report the relevant situation of project […]