首先發送請求,然後處理響應。我用.net寫的WebService,直接存取,點擊方法名稱可以看到執行個體代碼,只需要在asp中使用Microsoft.XMLHTTP發送請求,然後處理xml的結果就行了。
要注意Namespace不能寫錯了。
<%@language=vbscript codepage=936 %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<%
Dim strxml
Dim str
'定義soap訊息
strxml = "<?xml version='1.0' encoding='utf-8'?>"
strxml = strxml & "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
strxml = strxml & "<soap:Body> "
strxml = strxml & "<Decrypt xmlns='http://192.168.3.239:8000/3des/'>"
strxml = strxml & "<strIn>4Dv5esfHAh0=</strIn>"
strxml = strxml & "<strKey>Not.ceNte</strKey>"
strxml = strxml & "</Decrypt>"
strxml = strxml & "</soap:Body>"
strxml = strxml & "</soap:Envelope>"
Set h = createobject( "Microsoft.XMLHTTP")
'向指定的URL發送Post訊息
h.open "POST", "http://192.168.3.239:8000/3des/Service.asmx", False
h.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
h.setRequestHeader "Content-Length",LEN(strxml)
h.setRequestHeader "SOAPAction", "http://192.168.3.239:8000/3des/Decrypt"
h.send (strxml)
'顯示返回的XML資訊
If h.Status = 200 Then
Set xmlDOC = server.CreateObject("MSXML.DOMDocument")
xmlDOC.load(h.responseXML)
str = xmlDOC.childNodes(1).Text ''調用SHOWALLNODE
'遍曆並取出xml中的一個節點
Set Node = xmlDOC.getElementsByTagName("RegionID")
'for x=Node.length-1 to 0 step -1
regMgrID = Node.item(0).Text
'next
Set xmlDOC = nothing
response.write(str)
Else
Response.Write h.Status &" "
Response.Write h.StatusText
End if
%>
</body>
</html>