asp调用webservices
弄了一天 也算大功告成
1 打开dreamwear 新建asp(vbscript)页面
2 body标签之间:<%%>
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
<%
url = "http://192.168.1.7:8066/WebService/WebPayService.asmx" '服务地址
dim g_out_trade_no,g_total_fee,g_trade_status,gmt_payment,md5 '定义变量
g_out_trade_no=request("out_trade_no")'表单传递过来的值
g_total_fee=request("total_fee")
g_trade_status=request("trade_status")
gmt_payment=request("gmt_payment")
md5=""
'datetime=now
'if(g_out_trade_no="") then response.write("订单编号不能为空")%><br /><%
' if(g_total_fee="") then response.write("价格不能为空")%><br /><%
' if(g_trade_status="") then response.write("订单状态不能为空")%><br /><%
' response.End()
if (g_trade_status="TRADE_FINISHED") then
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:Body>"& _
"<AddWapPayInfo xmlns="&CHR(34)&"http://tempuri.org/"&CHR(34)&">"& _
"<orderno>"&g_out_trade_no&"</orderno>"& _ '对应服务方法参数orderno,money,datetime,md5code
"<money>"&g_total_fee&"</money>"& _
"<datetime>"&gmt_payment&"</datetime>"& _
"<md5code>"&gmt_payment&"</md5code>"& _
"</AddWapPayInfo>"& _ 'AddWapPayInfo 为服务命名空间 必须相同
"</soap:Body>"& _
"</soap:Envelope>"
Set xmlDOC =Server.CreateObject("MSXML.DOMDocument")
Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
xmlhttp.setRequestHeader "HOST","192.168.1.7"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/AddWapPayInfo"
xmlhttp.Send(SoapRequest)
bOK = xmlDOC.load(xmlhttp.responseXML)
if xmlhttp.Status=200 then
xmlStr = xmlDOC.xml
strFlag = xmlDOC.documentElement.childNodes.item(0).text
if strFlag="ok" then
strContent = "支付成功!"
else
strContent= strFlag
end if
Response.Write strContent
else
strContent = "提取信息失败!"
Response.Write xmlhttp.StatusText
Response.Write strContent
end if
Set xmlhttp = Nothing
Set xmlDOC = Nothing
else response.Write("fail")
end if
%>
url = "http://192.168.1.7:8066/WebService/WebPayService.asmx" '服务地址
dim g_out_trade_no,g_total_fee,g_trade_status,gmt_payment,md5 '定义变量
g_out_trade_no=request("out_trade_no")'表单传递过来的值
g_total_fee=request("total_fee")
g_trade_status=request("trade_status")
gmt_payment=request("gmt_payment")
md5=""
'datetime=now
'if(g_out_trade_no="") then response.write("订单编号不能为空")%><br /><%
' if(g_total_fee="") then response.write("价格不能为空")%><br /><%
' if(g_trade_status="") then response.write("订单状态不能为空")%><br /><%
' response.End()
if (g_trade_status="TRADE_FINISHED") then
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:Body>"& _
"<AddWapPayInfo xmlns="&CHR(34)&"http://tempuri.org/"&CHR(34)&">"& _
"<orderno>"&g_out_trade_no&"</orderno>"& _ '对应服务方法参数orderno,money,datetime,md5code
"<money>"&g_total_fee&"</money>"& _
"<datetime>"&gmt_payment&"</datetime>"& _
"<md5code>"&gmt_payment&"</md5code>"& _
"</AddWapPayInfo>"& _ 'AddWapPayInfo 为服务命名空间 必须相同
"</soap:Body>"& _
"</soap:Envelope>"
Set xmlDOC =Server.CreateObject("MSXML.DOMDocument")
Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
xmlhttp.setRequestHeader "HOST","192.168.1.7"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/AddWapPayInfo"
xmlhttp.Send(SoapRequest)
bOK = xmlDOC.load(xmlhttp.responseXML)
if xmlhttp.Status=200 then
xmlStr = xmlDOC.xml
strFlag = xmlDOC.documentElement.childNodes.item(0).text
if strFlag="ok" then
strContent = "支付成功!"
else
strContent= strFlag
end if
Response.Write strContent
else
strContent = "提取信息失败!"
Response.Write xmlhttp.StatusText
Response.Write strContent
end if
Set xmlhttp = Nothing
Set xmlDOC = Nothing
else response.Write("fail")
end if
%>
3 建立虚拟目录 访问
搞定 收工