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,"<","<",1,-1,1)
xmlStr = Replace(xmlStr,">",">",1,-1,1)
Response.Write xmlStr
else
Response.Write objHTTP.Statu & "<br>"
Response.Write objHTTP.StatusText
end if
%>