Processing method of sending and receiving XML data using ASP

Source: Internet
Author: User
Because you want to do some of the mobile Dream Network WAP interface, so to use this way, there will be a asp.net version, this is an ASP version, using the msxml2.xmlhttp image.

Request.asp
Dim Https
Set Https=server.createobject ("MSXML2. XMLHTTP ")
' Define a XMLHTTP pair like
Https.open "POST", "http://127.0.0.1/testpost/response.asp", False
Https.send "<?xml version=" "1.0" "><misc_command version=" "1.6" "><command_name>echo</command" _name>
<command_data_block><sid>123456</sid><service_id>987654</service_id>
<sp_id>11111</sp_id><sp_password>22222</sp_password></command_data_block></ Misc_command> "
If Https.readystate=4 Then
Response.Write "submitted successfully"
' ReadState read status is 4 successful, continue behind, unsuccessful, of course, there is no need to continue processing
Dim objstream
Set objstream = Server.CreateObject ("ADODB.stream")
' Define a stream, because read it directly out of the garbled, so have to deal with
Objstream. Type = 1
Objstream. Mode =3
Objstream. Open
Objstream. Write Https.responsebody
Objstream. Position = 0
Objstream. Type = 2
Objstream. Charset = "GB2312"
html = objstream. ReadText
' Turn your code, put it in the HTML, and close these pairs.
Objstream. Close
Set objstream = Nothing
Set https=nothing
End If
Response.Write html

Response.asp

' Create a DOMDocument object
Set XML = Server.CreateObject ("MSXML2.") DOMDocument ")
Xml.async = False

' Load post data
Xml. Load Request
If xml.parseError.errorCode <> 0 Then
Response.Write "cannot receive data correctly" & Description: "& Xml.parseError.reason &" <br> Line: & Xml.parseError.Line
End If

Set Blogchild=xml.getelementsbytagname ("Misc_command")
' The_text=blogchild.item (0). childnodes (1). Text
' The_text=blogchild.item (0). Text
' For i=0 to Blogchild.length-1
Response.Write The_text
With this approach, it is easy to invoke the servlet or Web service in the ASP!

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.