从经典ASP向RESTful WS发送JSON字符串 [英] Send a JSON string to a RESTful WS from Classic ASP
本文介绍了从经典ASP向RESTful WS发送JSON字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我基本上是经典ASP和VBScript的菜鸟,所以我想获得一些帮助,以实现我在这里实现的目标.我已经构建了一个JSON字符串,并且需要使用VBScript将其发送到RESTful Web服务.我该怎么办?
I am basically a noob in classic ASP and VBScript, so I would like to get some help to achieve the goal I have here. I've built a JSON string and I need to send it to a RESTful web service using VBScript. How do I do that?
我有一些代码,但是我认为它不起作用:
I have some code, but I don't think it works:
strJSONToSend = JSONstr 'this is where I use my built JSON string
webserviceurl = "url here"
Set objRequest = Server.createobject("MSXML2.XMLHTTP.3.0")
objRequest.open "POST", webserviceurl, False
objRequest.setRequestHeader "Content-Type", "application/json; charset=UTF-8"
objRequest.setRequestHeader "CharSet", "utf-8"
objRequest.setRequestHeader "SOAPAction", webserviceurl
Set objJSONDoc = Server.createobject("MSXML2.DOMDocument.3.0")
objJSONDoc.loadXml strJSONToSend
objRequest.send objJSONDoc
set objJSONDoc = nothing
set objResult = nothing
推荐答案
您不需要将JSON转换为XML(因为它是JSON而不是XML和全部):
You don't need to convert the JSON to XML (since it's JSON and not XML and all):
strJSONToSend = JSONstr 'this is where I use my built JSON string
webserviceurl = "url here"
Set objRequest = Server.createobject("MSXML2.XMLHTTP.3.0")
objRequest.open "POST", webserviceurl, False
objRequest.setRequestHeader "Content-Type", "application/json; charset=UTF-8"
objRequest.setRequestHeader "CharSet", "utf-8"
objRequest.setRequestHeader "SOAPAction", webserviceurl
objRequest.send strJSONToSend
set objJSONDoc = nothing
set objResult = nothing
这篇关于从经典ASP向RESTful WS发送JSON字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文