在http://www.lasertools.co.uk/webservice/getCatalogue.asmx有一个web服务我需要使用它接受SOAP 1.1和SOAP 1.2请求,但我没有使用经典ASP的经验;我已经阅读了几篇关于它的文章,并尝试了这些文章中提到的一些方法,但我似乎无法让它工作。到目前为止我所管理的最好的是来自服务器的响应,其中说找不到404页面。这是我目前正在尝试的ASP页面:
<%@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>
答案 0 :(得分:1)
404回应是可以预期的;你没有张贴到正确的网址:
postUrl = "http://www.lasertools.co.uk/webservice/getCatalogue.asmx"
请查看http://www.lasertools.co.uk/webservice/getCatalogue.asmx?op=getProductCategories上的示例。
当然,您发送的XML可能存在更多问题,但除非您mark it as code,否则此网站会删除括号内的任何内容。