vbscript 调用 web service
<!DOCTYPE HTML PUBLIC "-//W
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
</head>
<body>
<script language="vbscript">
'vb调用web Server
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Set xmlDOC =CreateObject("MSXML.DOMDocument")
strWebserviceURL = "http://localhost/study/webService.asmx/ADD"
'设置参数及其值
strRequest = "a=2&b=3"
objHTTP.Open "POST", strWebserviceURL, False
'设置这个Content-Type很重要
objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.Send(strRequest)
bOK = xmlDOC.load(objHTTP.responseXML)
'看看状态值
//msgBox objHTTP.Status
//msgbox objHTTP.StatusText
'objHTTP.Status=200,这里就可以处理返回的xml片段了
'如果需要,可以替换返回的xml字符串当中的<和>
xmlStr = xmlDOC.xml
xmlStr = Replace(xmlStr,"<","<",1,-1,1)
xmlStr = Replace(xmlStr,">",">",1,-1,1)
'取结果
'用正则表达式取出结果
Set re = New RegExp
re.Pattern = "<(.*)(.*)>(.*)<\/\1>"
re.Global = True
re.IgnoreCase = True
re.MultiLine = True
xmlStr=re.Replace(xmlStr,"$3")
re.Pattern = "<?.*?>"
xmlStr=re.Replace(xmlStr,"")
'显示结果
msgbox xmlStr
</script>
</body>
</html>