用一下脚本访问,提示NoService<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="vbscript">
Dim url,xmlhttp,dom,node,xmlDOC
'根据webservice的测试页不同的方法构造不同的soap request
SoapRequest = "<?xml version="&CHR(34)&"1.0"&CHR(34)&" encoding="&CHR(34)&"utf-8"&CHR(34)&"?>"& _
"<soap:Envelope xmlns:xsi="&CHR(34)&"http://www.w3.org/2001/XMLSchema-instance"&CHR(34)&" "& _
"xmlns:xsd="&CHR(34)&"http://www.w3.org/2001/XMLSchema"&CHR(34)&" "& _
"xmlns:soap="&CHR(34)&"http://schemas.xmlsoap.org/soap/envelope/"&CHR(34)&">"& _
"<soap:Body>"& _
"<add xmlns="&CHR(34)&"http://localhost"&CHR(34)&">"& _
"<x>3</x>"& _
"<y>4</y>"& _
"</add>"& _
"</soap:Body>"& _
"</soap:Envelope>"
'url = "http://www.xxxx.com/Service1.asmx?methodname=Add"
url = "http://localhost:7001/webApp/services/ws/add"
Set xmlDOC =CreateObject("MSXML.DOMDocument")
xmlDOC.loadXML(SoapRequest)
Set xmlhttp = CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
'SOAPAction这个Header头同样可以在sample中找到
xmlhttp.setRequestHeader "SOAPAction", "http://localhost:7001/webApp/services/ws"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.Send(xmlDOC)
msgbox xmlhttp.Status
msgbox xmlhttp.StatusText
msgbox xmlhttp.responseText
If xmlhttp.Status = 200 Then
xmlDOC.load(xmlhttp.responseXML)
msgbox "执行结果为:"&xmlDOC.getElementsByTagName("addResult")(0).text
else
msgbox "failed"
end if
</script></HEAD><BODY></BODY>
</HTML>