<%@ 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("
")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 %>