0
在http://www.lasertools.co.uk/webservice/getCatalogue.asmx有一個Web服務,我需要使用它接受SOAP 1.1和SOAP 1.2請求,但我沒有經典的ASP經驗;我已經閱讀了幾篇關於它的文章,並嘗試了這些文章中提到的一些方法,但我似乎無法使其工作。到目前爲止,我所管理的最好的服務器響應是404頁面未找到。這裏是我正在嘗試的ASP頁面:經典ASP中的SOAP問題
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<%
Dim objXML
Dim postUrl
Dim DataToSend
Dim DataParms
Dim DataReceived
Dim Status
DataToSend = ""
DataParms = ""
postUrl = "http://www.lasertools.co.uk/webservice/GetProductCategories"
Set objXML = CreateObject("MSXML2.ServerXMLHTTP")
objXML.Open "POST", postUrl, False
objXML.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objXML.setRequestHeader "SOAPAction", "http://www.lasertools.co.uk/webservice/GetProductCategories"
objXML.setRequestHeader "MessageType", "CALL"
SOAPRequest = "<?xml version='1.0' encoding='utf-8'?> "
SOAPRequest = SOAPRequest & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"""
SOAPRequest = SOAPRequest & " xmlns:xsd=""http://www.w3.org/2001/XMLSchema"""
SOAPRequest = SOAPRequest & " xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
SOAPRequest = SOAPRequest & " <soap:Body>"
SOAPRequest = SOAPRequest & " <getProductCategories xmlns=""http://www.lasertools.co.uk/webservice"" />"
SOAPRequest = SOAPRequest & " </soap:Body>"
SOAPRequest = SOAPRequest & " </soap:Envelope>"
objXML.send SOAPRequest
DataReceived = objXML.responseText
Dim oXml
Set oXml = CreateObject("Msxml2.DOMDocument")
oXml.LoadXml (DataReceived)
oXML.async = False
Set objLst = oXml.getElementsByTagName("*")
if objLst.Length = 0 then
%>
<br />NO CHOICES<br />
<%
response.write DataReceived & "<br />"
else
AvailableChoices = 0
For Each xmlItem In objLst
For Each xmlItem2 In xmlItem.childNodes
if xmlItem.childNodes(0).NodeName = "#text" then
AvailableChoices = AvailableChoices + 1
DisplayVal = xmlItem.childNodes(0).text
%>
<%=DisplayVal%><br />
<%
end if
Next
Next
end if
%>
<body>
</body>
</html>
哇,我簡直不敢相信那麼簡單 - 我嘗試了幾十種代碼組合!謝謝 – Mike 2011-03-05 12:42:07
沒問題邁克。那麼你能接受這個答案嗎? (點擊此答案左邊的複選框)。 – Martijn 2011-03-05 12:43:52