Set xmlhttp = server. CreateObject ("Msxml2.xmlhttp")
xmlHTTP. Open "POST", Url,false
Xmlhttp.setrequestheader "Content-type", "Text/xml"; Charset=utf-8 "
Xmlhttp.setrequestheader "HOST", "192.100.100.81"
Xmlhttp.setrequestheader "Content-length", LEN (Soaprequest)
Xmlhttp.setrequestheader "SOAPAction", "http://tempuri.org/LoginByAccount" must be the same as the WebService namespace, otherwise the service will reject
xmlHTTP. Send (Soaprequest)
' This makes use of XMLHTTP to successfully send a SOAP request with the SOAP sample.
' Check for success:
Response.Write XMLHTTP. status& ""
Response.Write XMLHTTP. StatusText
Set xmlhttp = Nothing
%>
If success will show OK, unsuccessful will show 500 internal server error? Connection:keep-alive.
Once successful, you can take advantage of the WebService response, as follows:
SOAP response Sample
The following is an example of a SOAP response. The displayed placeholder needs to be replaced by the actual value.
http/1.1 OK
Content-type:text/xml; Charset=utf-8
Content-length:length
<?xml version= "1.0" encoding= "Utf-8"?
<soap:envelope xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd= "Http://www.w3.org/2001/XMLSchema "Xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/"
<soap:Body>
<loginbyaccountresponse xmlns= "http://tempuri.org/"
<LoginByAccountResult> string </LoginByAccountResult>
</LoginByAccountResponse>
</soap:Body>
</soap:Envelope>
This is an example of the SOAP response that corresponds to the sample SOAP request, and you can view the response after the request has been successfully sent:
If XMLHTTP. Status = Then
End If
The correct request gives a full response, the request is incorrect (such as account number, password is not correct) the content of the response will be incomplete.
Remove the data from the response as follows:
If XMLHTTP. Status = Then
Set xmldoc = server. CreateObject ("MSXML"). DOMDocument ")
Xmldoc.load (Xmlhttp.responsexml)
Response.Write XmlDOC.documentElement.selectNodes ("//loginbyaccountresult") (0). Text ' Display data with Loginbyaccountresult nodes (encoded to decode)
Set xmldoc = Nothing
Displays the function of individual properties and data for a node:
Function Showallnode (Rootname,myxmldoc) ' Hope everyone is constantly finished Shanshan 2005-1-9 writed by 844
If Rootname <> "" Then
Set Nodeobj=myxmldoc.documentelement.selectsinglenode ("//&rootname&") ' current node pair image
Nodeattributelen=myxmldoc.documentelement.selectsinglenode ("//&rootname&"). Attributes.length ' current node attribute number
If Nodeobj.text <> "" Then
Text of the returnstring=returnstring& <BR> node: ("&nodeobj.text&")
End If
returnstring=returnstring& "<BR> {<BR>"
If Nodeattributelen <> 0 Then
returnstring=returnstring& <BR> The number of properties is &nodeAttributelen&, respectively: "
End If
For I=0 to NodeAttributelen-1
returnstring=returnstring& "<li>" &nodeobj.attributes (i). name& ":" &nodeobj.getattribute (Nodeobj.attributes (i)). Name) & "</li>"
Next
If Nodeobj.childNodes.Length <> 0 Then
If Nodeobj.haschildnodes () and LCase (Nodeobj.childNodes.item (0). nodename) <> #text "Then" has child nodes
Set Childnodeobj=nodeobj.childnodes
Childnodelen=nodeobj.childnodes.length
returnstring=returnstring& "<BR> <BR> has a" &childnodelen& "child node; The <BR> is: "
For I=0 to Childnodelen-1
returnstring=returnstring& "<li>" &childnodeobj.item (i) .nodename& "</li>"
Next
End If
End If
returnstring=returnstring& "<BR>} <BR>"
Response.Write returnstring
Set nodeobj=nothing
End If
End Function
You can use this:
If XMLHTTP. Status = Then
Set xmldoc = server. CreateObject ("MSXML"). DOMDocument ")
Xmldoc.load (Xmlhttp.responsexml)
Showallnode "Loginbyaccountresponse", xmldoc ' call Showallnode
Set xmldoc = Nothing
Two Post Request Example
HTTP POST
The following is an example of an HTTP POST request. The displayed placeholder needs to be replaced by the actual value.
Post/webservice1/usersignon.asmx/loginbyaccount http/1.1
host:192.100.100.81
content-type:application/x-www-form-urlencoded
Content-length:length
Username=string&password=string
To construct a POST request:
<%
url = "Http://192.100.100.81/WebService1/UserSignOn.asmx/LoginByAccount"
Set xmlhttp = server. CreateObject ("Msxml2.xmlhttp")
xmlHTTP. Open "POST", Url,false
Xmlhttp.setrequestheader "Content-type", "application/x-www-form-urlencoded" ' attention
Xmlhttp.setrequestheader "HOST", "192.100.100.81"
Xmlhttp.setrequestheader "Content-length", LEN (Soaprequest)
xmlHTTP. Send (Soaprequest)
' This will successfully send a POST request with the HTTP POST sample by using XMLHTTP.
' Check for success:
Response.Write XMLHTTP. status& ""
Response.Write XMLHTTP. StatusText
Set xmlhttp = Nothing
%>
If success will show OK, unsuccessful will show 500 internal server error? Connection:keep-alive.
Once successful, you can take advantage of the WebService response, as follows:
HTTP POST
The following is an example of an HTTP POST response. The displayed placeholder needs to be replaced by the actual value.
http/1.1 OK
Content-type:text/xml; Charset=utf-8
Content-length:length
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.