XMLHTTP. Send (varbody) varbody: instruction set. It can be XML data, a string, a stream, or an unsigned integer array. It can also be omitted, so that the command can be substituted by the URL parameter of the open method. Data transmission methods can be synchronous or asynchronous. In asynchronous mode, once a packet is sent, the send process is terminated and the client performs other operations. In synchronous mode, the client waits until the server returns a confirmation message to terminate the send process.
Method 1: varbody is omitted, so that the instruction can be substituted by the URL parameter of the open method.
VaR post = "id = 1000 & page = 1 ";
VaR dourl = "T. asp" + post
XMLHTTP. Open ("Post", dourl, false );
XMLHTTP. Send (null );
This method directly uses request. querystring ("parameter name") in ASP ")
Method 2: varbody is a string, the open method is defined as post, and is uploaded as a form.
VaR post = "id = 1000 & page = 1 ";
VaR dourl = "T. asp ";
XMLHTTP. Open ("Post", dourl, false );
XMLHTTP. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ");
XMLHTTP. Send (post );
This method directly uses request. Form ("parameter name") in ASP ")
Method 3: varbody is in XML format.
VaR xmldom = new activexobject ("msxml2.domdocument ");
Xmldom. loadxml ("<userinfo> <username> User Name </username> <usersex> male </usersex> <usertel> 028 </usertel> <useremail> </ userinfo> ");
XMLHTTP. Open ("Post", "T. asp", false );
XMLHTTP. Send (xmldom. XML );
When this method is used, the server uses
<%
Response. contenttype = "text/XML"
Response. charset = "gb2312"
Dim xmldom
Set xmldom = server. Createobject ("Microsoft. xmldom ")
Xmldom. async = true
Xmldom. Load (request)
Response. Write xmldom. xml
%>
You can get the relevant content in XM.
The client uses Delphi, and the server uses the dot net MVC Architecture to obtain parameters. Example:
Delphi client:
Code unit unit1;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, comobj, stdctrls;
Type
Tform1 = Class (tform)
Buttonok: tbutton;
Editurl: tedit;
Editparam: tedit;
Labelurl: tlabel;
Labelparam: tlabel;
Label1: tlabel;
Label2: tlabel;
Procedure buttonokclick (Sender: tobject );
Private
{Private Declarations}
Public
{Public declarations}
End;
VaR
Form1: tform1;
Implementation
{$ R *. DFM}
Procedure tform1.buttonokclick (Sender: tobject );
VaR
URL: string;
XMLHTTP, Param: olevariant;
Responsetext: widestring;
Begin
Try
URL: = 'HTTP: // localhost/siteweb/authentication/logonx ';
Param: = 'regionno = 123456 & code = kingly & Password = 1 ';
XMLHTTP: = createoleobject ('msxml2. xmlhttp.3.0 ');
XMLHTTP. Open ('post', URL, false );
XMLHTTP. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded'); // This sentence is critical, otherwise the server will not detect the Parameter
XMLHTTP. Send (PARAM );
Responsetext: = XMLHTTP. responsetext; // returned result
Showmessage (responsetext );
Except t on E: exception do
Showmessage (E. Message );
End;
End;
End.
Dot NET Server Syntax:
Code [Acceptverbs (httpverbs. Post)]
[Predictionfilter ()]
Public void logonx ()
{
String errmsg = string. empty;
Guid loginid = guid. empty;
Response. contenttype = "text/XML ";
If (request. Form ["registerno"] = NULL)
Errmsg = "registerno is empty ";
If (request. Form ["code"] = NULL)
Errmsg = "code is empty ";
If (request. Form ["password"] = NULL)
Errmsg = "password is blank ";
If (! String. isnullorempty (errmsg ))
{
Response. Write (errmsg );
Response. End ();
}
String registerno = request. Form ["registerno"]. tostring ();
String code = request. Form ["code"]. tostring ();
String Password = request. Form ["password"]. tostring ();
If (! Validatelogon (registerno, code, password ))
{
Errmsg = "the parameter is blank ";
Response. Write (errmsg );
Response. End ();
}
Try
{
// Call the server logon interface to obtain the value of loginid...
}
Catch (exception ex)
{
Errmsg = ex. message;
}
If (! String. isnullorempty (errmsg ))
Response. Write (errmsg );
Else
Response. Write (loginid );
Response. End ();