asp 访问WebService 基于SOAP

<%
'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,"<","&lt;")
   xmlStr = Replace(xmlStr,">","&gt;")
   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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值