【发布时间】:2012-03-16 08:11:39
【问题描述】:
我是开发网络服务的初学者,所以请帮助解决我的问题
我需要创建一个 VBS(VBScript) 文件,说明如何创建 json 字符串以及将 json 对象传递给 java restful webservice
以下是我的代码,但它不是 json 形式,所以请帮助创建对象的 json 形式
surl="http://localhost:8080/de.vogella.jersey.first/rest/hello/add"
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
json="name="+strComputer+"&age=24"
'json="name=strComputer&age=24"
HTTPPost sUrl,json
Function HTTPPost(sUrl,json)
'Microsoft.XMLHTTP
set OHTTP = CreateObject("MSXML2.serverXMLHTTP")
OHTTP.open "POST",surl,false
msgbox(surl & json)
OHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
OHTTP.setRequestHeader "Content-Length","Len(json)"
OHTTP.setRequestHeader "Pragma","no-cache"
OHTTP.setRequestHeader "Expires","-1"
OHTTP.setRequestHeader "Connection","close"
OHTTP.send json
'HTTPPOST = oHTTP.responseText
msgbox(OHTTP.responseText)
End Function
提前感谢您在我的问题上花费宝贵的时间
【问题讨论】:
标签: java json vbscript restful-authentication