ASPを利用してXMLデータを送受信する処理方法とコード
2131 ワード
モバイル夢路WAPのいくつかのインターフェースをするため、このような方式を使って、次はASP.netバージョンがあります。これはASPバージョンで、MSXML 2.XMLHTTPペアを利用しました。 request.asp
dim Https
set Https=server.createobject("MSXML2.XMLHTTP")
' XMLHTTP
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 " "
'readstate 4 , ,
dim objstream
set objstream = Server.CreateObject("adodb.stream")
' stream, ,
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write Https.responseBody
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312"
html = objstream.ReadText
' , html ,
objstream.Close
set objstream = nothing
set https=nothing
end if
response.write html
response.asp
' DOMDocument
Set xml = Server.CreateObject ("msxml2.DOMDocument")
xml.async = False
' POST
xml.Load Request
If xml.parseError.errorCode <> 0 Then
response.write " " & "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
この方法を利用して、ASPでServletまたはWebを呼び出します。 サービスはとても楽です。