博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ASP XML处理&接口调用
阅读量:6515 次
发布时间:2019-06-24

本文共 6824 字,大约阅读时间需要 22 分钟。

<%@ Language=VBScript %><%Option ExplicitClass cTest    dim str        'str="print success!"    sub print()        'dim str        str="print success!"        response.Write (str)    End subEnd Classsub submitTest()    response.write("URL="&Request.ServerVariables("URL")&"
") response.write("QUERY_STRING="&Request.ServerVariables("QUERY_STRING")&"
") response.write("
") response.write("
") response.write("
") response.write("
")end subFunction SendSoaRequest(xmlResponse,requestType) dim returnValue,obj,ResponseInfo set obj = new Cls_SOA_Service with obj '.UserId="110254" .UserId="Customer.WSUser" '! .RequestType = requestType .requestXML = xmlResponse If .Request then returnValue = .ObjXmlDoc.text else returnValue = "" end if end with SendSoaRequest = returnValueEnd Functionfunction getSOA() dim requestType,xmlResponse,xmlRequest,strXML,res requestType = "Customer.User.Service.GetAllianceInfoFromSession" xmlRequest= "
" xmlRequest = xmlRequest & "
_zh_baidu
" xmlRequest = xmlRequest & "
1
" xmlRequest = xmlRequest & "
http://www.sina.com.cn
" xmlRequest = xmlRequest &"
" '调用soa接口 xmlResponse = SendSoaRequest(xmlRequest,requestType) response.Write (xmlResponse&"
") '-- 'xmlResponse = "
" 'xmlResponse = xmlResponse &"
" 'xmlResponse = xmlResponse &"
" 'xmlResponse = xmlResponse &"
T
" 'xmlResponse = xmlResponse &"
1
" 'xmlResponse = xmlResponse &"
449
" 'xmlResponse = xmlResponse &"
" 'xmlResponse = xmlResponse &"
U449
" 'xmlResponse = xmlResponse &"
" 'xmlResponse = xmlResponse &"
" 'XML处理 res= CreateXML(xmlResponse)End function'=调用==============Dim iRetCode,iAlliance_RVPID_Out,iAlliance_RVPID_inDim sEid,iAllianceID,dtDataChange_lastTime,sEidName'Form提交测试'call submitTest()'SOA测试'call getSOA()'类测试(作用域)'dim obj'set obj =new cTest'call obj.print()'-------------------------------------------------------------------------'XML解析 遍历测试!dim strXMLstrXML=""strXML=strXML & "
"strXML=strXML & "
"strXML=strXML & "
Harry Potter"strXML=strXML & "
J K. Rowling
"strXML=strXML & "
2005
"strXML=strXML & "
29.99
"strXML=strXML & "
"strXML=strXML & "
"strXML=strXML & "
Everyday Italian"strXML=strXML & "
Giada De Laurentiis
"strXML=strXML & "
2005
"strXML=strXML & "
30.00
"strXML=strXML & "
"strXML=strXML & "
"strXML=strXML & "
Learning XML"strXML=strXML & "
Erik T. Ray
"strXML=strXML & "
2003
"strXML=strXML & "
39.95
"strXML=strXML & "
"strXML=strXML & "
"strXML=strXML & "
XQuery Kick Start"strXML=strXML & "
James McGovern
"strXML=strXML & "
Per Bothner
"strXML=strXML & "
Kurt Cagle
"strXML=strXML & "
James Linn
"strXML=strXML & "
Vaidyanathan Nagarajan
"strXML=strXML & "
2003
"strXML=strXML & "
49.99
"strXML=strXML & "
"strXML=strXML & "
"'解析call analyseXML(strXML)Function analyseXML(strXML) dim retXml,requestInfo,nodes set requestInfo = Server.CreateObject("msxml2.DOMDocument") requestInfo.validateOnParse = false requestInfo.async = false requestInfo.loadXML(strXML) 'root节点 dim rootNode Set rootNode = requestInfo.selectSingleNode("bookstore") 'book节点列表 dim bookNodes,titleNode,textNode Set bookNodes = rootNode.childNodes dim Node,iLoop,jLoop for each Node in bookNodes response.Write ("<book ") for iLoop=0 to Node.attributes.length-1 if (Node.attributes(jLoop).nodetype=2) then response.Write (Node.attributes(iLoop).name&"="""&Node.attributes(iLoop).value&""" ") end if next response.Write (">
") iLoop=0 'response.Write (Node.ChildNodes.length &" ") for iLoop=0 to Node.ChildNodes.length-1 response.Write (" <"&Node.ChildNodes(iLoop).nodename) for jLoop=0 to Node.ChildNodes(iLoop).attributes.length-1 if (Node.attributes(jLoop).nodetype=2) then response.Write (" "&Node.ChildNodes(iLoop).attributes(jLoop).name&"="""&Node.ChildNodes(iLoop).attributes(jLoop).value&""" ") end if next response.Write (">" & Node.ChildNodes(iLoop).text) response.Write ("</"&Node.ChildNodes(iLoop).nodename&">
") next response.Write ("</book>
") next ''-------------------------------------------------------------------- ''第4个book的第3个节点 i=3,j=2 'dim i,j 'i=3 'j=2 'response.Write ("
nodename=" & bookNodes.item(i).ChildNodes(j).nodename & ",text=" & bookNodes.item(i).ChildNodes(j).text & "
") 'response.Write ("
nodename=" & bookNodes.item(i).ChildNodes(j).nodename & ",text=" & bookNodes.item(i).ChildNodes(j).text & "
") ''属性 'dim bookNode_n,attr 'Set bookNode_n = rootNode.childNodes.item(3) 'Set attr = bookNode_n.attributes.getNamedItem("category") '--注意大小写 'response.Write ("Attribute="&attr.Value) '--------------------------------------------------------------------End FunctionFunction CreateXML(xmlResponse) 'xmlResponse= "
" 'xmlResponse = xmlResponse &"
T
" 'xmlResponse = xmlResponse &"
1
" 'xmlResponse = xmlResponse &"
449
" 'xmlResponse = xmlResponse &"
" 'xmlResponse = xmlResponse &"
U449
" 'xmlResponse = xmlResponse &"
" if xmlResponse="" then CreateXML="" else dim retXml,requestInfo,nodes set requestInfo = Server.CreateObject("msxml2.DOMDocument") requestInfo.validateOnParse = false requestInfo.async = false requestInfo.loadXML(xmlResponse) If ucase(requestInfo.selectSingleNode("/Response/Header/@ResultCode").Value)="SUCCESS" then dim iAllianceId,iSid iAllianceId=requestInfo.selectSingleNode("/Response/GetAllianceInfoFromSessionResponse/AllianceID").text iSid =requestInfo.selectSingleNode("/Response/GetAllianceInfoFromSessionResponse/SID").text response.Write ("iAllianceId="&iAllianceId&",iSid="&iSid) End If End ifEnd Function %>

 

转载于:https://www.cnblogs.com/streetpasser/archive/2013/04/01/2993570.html

你可能感兴趣的文章
关于 Linux
查看>>
图文解析五大外链误区
查看>>
ios开发之导航控制器的原理
查看>>
《Netkiller Blockchain 手札》Hyperledger Fabric Java SDK Demo
查看>>
Linux系统_Centos7下安装Nginx
查看>>
《PHP和MySQL Web 开发》 第12章 MySQL高级管理
查看>>
数据库设计 Step by Step (6) —— 提取业务规则
查看>>
Redis客户端redisson实战
查看>>
连接到 JasperReports Server
查看>>
java处理高并发高负载类网站问题
查看>>
使用C#生成随机密码(纯数字或字母)和随机卡号(数字与字母组合)
查看>>
CAS服务器端集群
查看>>
JAVA Collections框架
查看>>
进制转换
查看>>
ASCII码
查看>>
java常用四种排序源代码
查看>>
win7 下硬盘安装Redhat7
查看>>
Redis 分布式锁的正确实现方式
查看>>
mysqldump 备份命令使用中的一些经验总结
查看>>
程序猿知道英语词汇
查看>>