<%
'json 요청
set req = Server.CreateObject("Chilkat_9_5_0.HttpRequest")
req.HttpVerb = "POST"
req.Path = "/something"
req.ContentType = "text/plain"
set json = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = json.AppendString("username","my_username")
success = json.AppendString("password","my_password")
'배열추가
Set vFactors = json.AppendObject("validation-factors")
Set vArray = vFactors.AppendArray("validationFactors")
success = vArray.AddObjectAt(0)
Set factorObj = vArray.ObjectAt(0)
success = factorObj.AppendString("name","remote_address")
success = factorObj.AppendString("value","127.0.0.1")
json.EmitCompact = 0
JsonData = json.Emit()
set crypt = Server.CreateObject("Chilkat_9_5_0.Crypt2")
success = crypt.UnlockComponent("Anything for 30-day trial")
crypt.CryptAlgorithm = "none"
crypt.EncodingMode = "base64"
JsonData = crypt.EncryptStringENC(JsonData) 'BASE64 로 인코딩
success = req.LoadBodyFromString(JsonData,"euc-kr")
requestMime = req.GenerateRequestText()
Response.Write "<pre>" & Server.HTMLEncode( requestMime) & "</pre>"
set http = Server.CreateObject("Chilkat_9_5_0.Http")
Set resp = http.PostJson("http://test.co.kr/test.asp", requestMime)
response.write "리턴값 :<p>" & resp.BodyStr
'json 응답
set mime = Server.CreateObject ( "Chilkat_9_5_0.Mime")
success = mime.UnlockComponent("Anything for 30-day trial")
If Request.TotalBytes > 0 Then
Dim lngBytesCount
lngBytesCount = Request.TotalBytes
jsonstring = BytesToStr(Request.BinaryRead(lngBytesCount))
success = mime.LoadMime(jsonstring)
jsonstring = mime.GetEntireBody() '본문스트링
'디코딩
set crypt = Server.CreateObject("Chilkat_9_5_0.Crypt2")
crypt.CryptAlgorithm = "none"
crypt.EncodingMode = "base64"
response.write "<p>원본메시지:<br>" & jsonstring
jsonstring = crypt.DecryptStringENC(jsonstring)
response.write "<p>BASE64 디코딩:<br>" & jsonstring
Dim i, json, success, JsonCnt
set json = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = json.Load(jsonstring)
JsonCnt = json.Size
Dim Name, Value
For i = 0 To JsonCnt - 1
Name = json.NameAt(i)
Value = json.StringAt(i)
Next
End If
Function BytesToStr(bytes)
Dim Stream
Set Stream = Server.CreateObject("Adodb.Stream")
Stream.Type = 1 'adTypeBinary
Stream.Open
Stream.Write bytes
Stream.Position = 0
Stream.Type = 2 'adTypeText
Stream.Charset = "utf-8"
BytesToStr = Stream.ReadText
Stream.Close
Set Stream = Nothing
End Function
%>