Asp调用WebService事例
ASP调用Web服务事例
<%
'通过asp程序访问webService服务,取出议案并显示。
'取出参数公司代码(code)
'code = trim(Request("code"))
code = "012345"
'定义变量,议案的内容
dim strContent,strFlag
%>
<%
Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP")
Set xmlDOC =Server.CreateObject("MSXML.DOMDocument")
'strWebserviceURL="http://"+request.ServerVariables("SERVER_NAME")+":8008/CenterWS/CenterWS.asmx/Get_Blance"
'strWebserviceURL="http://IP:端口/CenterWS/CenterWS.asmx/Get_Blance"
'strWebserviceURL="http://IP:端口号/CenterWS/CenterWS.asmx/Get_Blance"
''strWebserviceURL="http://localhost:8008/CenterWS/CenterWS.asmx/Get_Blance"
strWebserviceURL="http://www.luckstock.net/CenterWS/CenterWS.asmx/Get_Blance"
tmp="RegisterInfoXML=<?xml version='1.0' encoding='gb2312'?><CorpInfo><Authorization><User>BillSurveyJoin</User><Password>xxYtrq2v7Nmrsw1</Password><Role>BillSurveyJoin</Role></Authorization><AppInfo><UserInfo ActionFlag='1'><add key='codes' value='"&code&"' /></UserInfo></AppInfo></CorpInfo>"
'Response.Write tmp
objHTTP.Open "POST", strWebserviceURL, False
objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.Send(tmp)
on error resume next
bOK = xmlDOC.load(objHTTP.responseXML)
on error resume next
'Response.Write objHTTP.Status
'Response.Write xmlStr
if objHTTP.Status=200 then
xmlStr = xmlDOC.xml
xmlStr = Replace(xmlStr,"<","<",1,-1,1)
xmlStr = Replace(xmlStr,">",">",1,-1,1)
'Response.Write xmlStr
'Response.Write xmlDOC.documentElement.selectNodes("//string")(0).text
strFlag = xmlDOC.documentElement.childNodes.item(0).text
if strFlag = "" or strFlag = "-1" then
strContent = "本公司目前暂无发起新的信息!"
else
strContent = strFlag
end if
'Response.Write strContent
else
strContent = "提取信息失败!"
'Response.Write objHTTP.StatusText
end if
%>
<%
'通过asp程序访问webService服务,取出议案并显示。
'取出参数公司代码(code)
'code = trim(Request("code"))
code = "012345"
'定义变量,议案的内容
dim strContent,strFlag
%>
<%
Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP")
Set xmlDOC =Server.CreateObject("MSXML.DOMDocument")
'strWebserviceURL="http://"+request.ServerVariables("SERVER_NAME")+":8008/CenterWS/CenterWS.asmx/Get_Blance"
'strWebserviceURL="http://IP:端口/CenterWS/CenterWS.asmx/Get_Blance"
'strWebserviceURL="http://IP:端口号/CenterWS/CenterWS.asmx/Get_Blance"
''strWebserviceURL="http://localhost:8008/CenterWS/CenterWS.asmx/Get_Blance"
strWebserviceURL="http://www.luckstock.net/CenterWS/CenterWS.asmx/Get_Blance"
tmp="RegisterInfoXML=<?xml version='1.0' encoding='gb2312'?><CorpInfo><Authorization><User>BillSurveyJoin</User><Password>xxYtrq2v7Nmrsw1</Password><Role>BillSurveyJoin</Role></Authorization><AppInfo><UserInfo ActionFlag='1'><add key='codes' value='"&code&"' /></UserInfo></AppInfo></CorpInfo>"
'Response.Write tmp
objHTTP.Open "POST", strWebserviceURL, False
objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.Send(tmp)
on error resume next
bOK = xmlDOC.load(objHTTP.responseXML)
on error resume next
'Response.Write objHTTP.Status
'Response.Write xmlStr
if objHTTP.Status=200 then
xmlStr = xmlDOC.xml
xmlStr = Replace(xmlStr,"<","<",1,-1,1)
xmlStr = Replace(xmlStr,">",">",1,-1,1)
'Response.Write xmlStr
'Response.Write xmlDOC.documentElement.selectNodes("//string")(0).text
strFlag = xmlDOC.documentElement.childNodes.item(0).text
if strFlag = "" or strFlag = "-1" then
strContent = "本公司目前暂无发起新的信息!"
else
strContent = strFlag
end if
'Response.Write strContent
else
strContent = "提取信息失败!"
'Response.Write objHTTP.StatusText
end if
%>