关闭

WEB客户端用ASP实现WEB服务的小例

标签: web服务aspwebparameterswebserviceservice
638人阅读 评论(0) 收藏 举报
分类:
The following snippet demonstrate how to use ASP to invoke a web service from remote server:
<%
Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP")
Set xmlDOC =Server.CreateObject("MSXML.DOMDocument")
'The following line indicate the WebService we will use.
' It takes 2 parameters as input and output their sum,i.e.
'a simple addition online caculator.
strWebserviceURL = "http://localhost/WebService/Service1.asmx/Add"
'setup parameters and their values
strRequest = "a=15&b=26"
objHTTP.Open "POST", strWebserviceURL, False
'Setup Content-Type
objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.Send(strRequest)
bOK = xmlDOC.load(objHTTP.responseXML)
'Check http status
if objHTTP.Status=200 then
xmlStr = xmlDOC.xml
xmlStr = Replace(xmlStr,"&lt;","<",1,-1,1)
xmlStr = Replace(xmlStr,"&gt;",">",1,-1,1)
Response.Write xmlStr
else
Response.Write objHTTP.Statu & "<br>"
Response.Write objHTTP.StatusText
end if
%>
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:44309次
    • 积分:691
    • 等级:
    • 排名:千里之外
    • 原创:24篇
    • 转载:2篇
    • 译文:0篇
    • 评论:10条
    最新评论