ACTIVE SERVER PAGE > Server.CreateObject("Msxml2.ServerXMLHTTP.3.0") - ¿ÜºÎ »çÀÌÆ® ºÒ·¯¿À±â
µî·ÏÀÏ : 2017-07-04 12:40
Á¶È¸¼ö : 52,659
¾Æ·¡ ¼Ò½ºÆ® ¼¹ö XML °´Ã¼ Msxml2.ServerXMLHTTP.3.0 ¸¦ ÀÌ¿ëÇÏ¿© ³×À̹ö ¸ÞÀÎȸéÀ» ºÒ·¯¿Í Ãâ·ÂÇØ º¸´Â ¿¹Á¦ÀÔ´Ï´Ù.
session.CodePage = "65001"
Response.CharSet = "utf-8"
set xml = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
xml.open "POST", "http://www.naver.com", false
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.send
res = xml.responseText
Set xml = Nothing
response.write res
¿À·ù 󸮴 Send ¸Þ½îµå¸¦ È£ÃâÇϱâ Àü¿¡ On Error Resume Next¸¦ Àû¾îÁÖ°í ¿À·ù¹ß»ý¿©ºÎ¸¦ üũÇÏ¸é µÈ´Ù.
On Error Resume Next
sUrl = "http://www.naver.com"
set xml = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send "subject=test&contents=message+body"
If Err Then
Response.Write "Error:" & xml.ParseError.URL
xml.ParseError.Reason
Else
Response.Write xml.ResponseText
End If
Set oHttp = Nothing
¹«¾ð°¡¸¦ º¸³ÂÀ¸¸é ¹Þ´Â°Ô ÀÖÀ»¼öµµ ÀÖ½À´Ï´Ù. ¹Þ´Â°Ç ½ºÆ®¸µ, ¹ÙÀ̳ʸ®, xmlµîÀÌ ÀÖ½À´Ï´Ù.
±×·¯¹Ç·Î È£ÃâÀÚÃø ÄÚµå´Â ¸¶Áö¸·À¸·Î ÀÌ·¸°Ô ³¡³³´Ï´Ù.
response.write xml.responseText
response.binarywrite xml.responsebody
response.write xml.responseXml.xml
ÇѱÛÆäÀÌÁö¸¦ ºÒ·¯¿Ã¶§´Â ¹ÙÀ̳ʸ®·Î ¿¾î¾ß ±ÛÀÚ°¡ ¾È±úÁý´Ï´Ù.
xml.open "get", "http:// ÇѱÛÆäÀÌÁöÁÖ¼Ò/page.asp", false
xml.send
response.binaryWrite xml.responseBody
¾Æ·¡´Â ¿¹Á¦ ¼Ò½º ÀÔ´Ï´Ù.
url = "http://entersoft.kr/test.asp"
tout = 3 * 2000 '' ŸÀӾƿô 6ÃÊ
Set xmlhttp = server.createObject("Msxml2.ServerXMLHTTP.3.0")
with xmlhttp
.setTimeouts tout, tout, tout, tout 'resolve, connect, send, receive
.open "POST", url, false
.send()
End with
' ADOÀÇ ½ºÆ®¸² °´Ã¼·Î ó¸®Çϱâ
' [ÀÌÀ¯] responseText ÇÁ¶óÆÛƼ´Â ¸®¸ðÆ®ÀÇ ÀÀ´äÀ» ¹«Á¶°Ç À¯´ÏÄÚµå·Î °£ÁÖÇÏ°í µðÄÚµùÇϹǷÎ
' À¯´ÏÄÚµå·Î ÀÎÄÚµùµÇÁö ¾ÊÀº °ÍµéÀº ¸ðµÎ ±ÛÀÚ°¡ ±úÁü
' µû¶ó¼ ÀÌ·¯ÇÑ °æ¿ì¿¡´Â responseText¸¦ Á÷Á¢ »ç¿ëÇÒ ¼ö°¡ ¾ø±â ¶§¹®¿¡
' ¸®¸ðÆ®ÀÇ ÀÀ´äÀ» µðÄÚµùµÇÁö ¾ÊÀº ÇüÅ·Π¹Þ¾Æ(responseBody ÇÁ¶óÆÛƼ¸¦ »ç¿ëÇÏ¸é µÊ)
' ÀûÀýÇÑ ÀÎÄÚµùÀ¸·Î º¯È¯ÇÑ µÚ¿¡ »ç¿ëÇϱâ À§ÇØ ADOÀÇ ½ºÆ®¸² °´Ã¼·Î ó¸®ÇÔ
Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open
adoStream.Position = 0 ' ½ºÆ®¸² °´Ã¼ÀÇ Å¸ÀÔÀ» º¯°æÇϱâ À§Çؼ± ¸ÕÀú ½ºÆ®¸²ÀÇ ÇöÀç Æ÷Áö¼ÇÀ» óÀ½À¸·Î ÁöÁ¤Çؾ߸¸ µÊ.
adoStream.Type = 1 ' ¸ÕÀú ½ºÆ®¸² °´Ã¼ÀÇ Å¸ÀÔÀ» ¹ÙÀ̳ʸ® ŸÀÔÀ¸·Î ÁöÁ¤
adoStream.Write xmlhttp.responseBody
adoStream.Position = 0 ' ´Ù½Ã ½ºÆ®¸² °´Ã¼ÀÇ Å¸ÀÔÀ» º¯°æÇϱâ À§ÇØ ÇöÀç Æ÷Áö¼ÇÀ» óÀ½À¸·Î ÁöÁ¤
adoStream.Type = 2 ' À̹ø¿¡´Â ½ºÆ®¸² °´Ã¼ÀÇ Å¸ÀÔÀ» ÅؽºÆ® ŸÀÔÀ¸·Î ÁöÁ¤
adoStream.Charset = "euc-kr" ' ¿øÇÏ´Â ÀÎÄÚµù À̸§À» ÁöÁ¤
resultStr = adoStream.ReadText
adoStream.Close
Set adoStream = Nothing
Set xmlhhtp = Nothing
Response.Write resultStr
Response.End