Processing Method and code for sending and receiving XML data using ASP

Source: Internet
Author: User

This method is used because of some interfaces of mobile dream WAP. The Asp.net version is available next. This is an ASP version, and msxml2.xmlhttp is used.
Request. asp CopyCode The Code is as follows: dim https
Set HTTPS = server. Createobject ("msxml2.xmlhttp ")
'Define an XMLHTTP object
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 reading status is 4, and the operation is successful. If the reading status is not successful, you do not need to proceed.
Dim objstream
Set objstream = server. Createobject ("ADODB. Stream ")
'Define a stream. You have to deal with it because it is garbled.
Objstream. type = 1
Objstream. mode = 3
Objstream. Open
Objstream. Write HTTPS. responsebody
Objstream. Position = 0
Objstream. type = 2
Objstream. charset = "gb2312"
Html = objstream. readtext
'Convert the code and put it in HTML to close these images.
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

using this method, it is easy to call servlet or Web Service in 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.