<%
'strTableName 表名
'strField 字段名称
'strWhere 条件
'nFlag 命令参数,0:添加,1:修改,2:删除
function getWebServiceData(strTableName,strField,strWhere,nFlag)
'url="http://192.168.1.160/usercenter3/LogonWS.asmx?methodname=KLManagerDataBase"
url="http://"&ipaddress&"/LogonWS.asmx"
dim xmlStr
set xmlhttp = server.createobject("msxml2.xmlhttp")
UserName="CNSEC.net"
PassWord="20080512"
strYDKey="cnsec20080512"
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:Header>"&_
"<CredentialSoapHeader xmlns="&CHR(34)&"http://www.cnsec.com/"&CHR(34)&">"&_
"<UserName>"&UserName&"</UserName>"&_
"<PassWord>"&PassWord&"</PassWord>"&_
"</CredentialSoapHeader>"&_
"</soap:Header>"&_
"<soap:Body>"& _
"<KLManagerDataBase xmlns="&CHR(34)&"http://www.cnsec.com/"&CHR(34)&">"& _
"<strTableName>"&strTableName&"</strTableName>"& _
"<strField>"& strField &"</strField>"& _
"<strWhere>"&strWhere&"</strWhere>"&_
"<nFlag>"&nFlag&"</nFlag>"&_
"<strYDKey>"&strYDKey&"</strYDKey>"& _
"</KLManagerDataBase>"& _
"</soap:Body>"& _
"</soap:Envelope>"
xmlhttp.open "post",url,false
xmlhttp.setrequestheader "content-type", "text/xml; charset=utf-8"
xmlhttp.setrequestheader "host",ipaddress
xmlhttp.setrequestheader "Content-Length",len(soaprequest)
xmlhttp.setRequestHeader "SOAPAction", "http://www.cnsec.com/KLManagerDataBase"
xmlhttp.send(soaprequest)
if xmlhttp.status = 200 then
Set xmlDOC =server.CreateObject("MSXML.DOMDocument")
xmlDOC.load(xmlhttp.responseXML)
xmlStr = xmlDOC.documentElement.selectNodes("//KLManagerDataBaseResult")(0).text
xmlStr = Replace(xmlStr,"<","<")
xmlStr = Replace(xmlStr,">",">")
getWebServiceData=xmlStr
response.Write(xmlStr)
Set xmlDOC=nothing
else
response.Write("<font color='red'>状态:"&xmlhttp.status&"</font>")
response.Write("<script language='javascript'>alert('请求WebService 出错了,请联系管理员!状态:"&xmlhttp.status&"');window.history.go(-1)</script>")
end if
set xmlhttp = nothing
end function
asp 访问WebService 基于SOAP
最新推荐文章于 2019-07-04 10:23:28 发布