通過WebService調用產品資料—-ASP用戶端執行個體

來源:互聯網
上載者:User

Response.Expires=-1 curPage=request.QueryString("curPage") Keywords=request.QueryString("keywords") if curPage="" then curPage="1" strMyICList=GetMyICListForHtml(43,curPage,30,keywords) Response.Write strMyICList Function GetMyICListForHtml(userID,curPage,pageSize,keywords) '######################################################### '函數名稱:GetMyICListForHtml '版本:For.ASP.V1.0 '功能描述:取得我的IC產品當前頁Html列表 '參數說明: ' userID 您的使用者ID 整型數字 ' curPage 當前要顯示的頁碼 整型數字 ' pageSize 每頁要顯示的產品數量 整型數字 ' keywords 搜尋關鍵詞(2個或2個以上字元) 字串 '返回說明: ' 返回IC產品當前頁Html列表 字串 '######################################################### 'On Error Resume Next err.Clear() '定義變數 Dim strUrl,strData Dim xmlHttp,xmlDoc,strResult strResult="" '初始 WebService URL strUrl="http://192.168.1.88/ECS/Products.asmx/GetMyICListForHtml" strData="userID=" & userID & _ "&curPage=" & curPage & _ "&pageSize=" & pageSize & _ "&keywords=" & keywords strUrl=strUrl & "?" & strData '建立XMLHTTP對象 Set xmlHttp = Server.CreateObject("Msxml2.XMLHTTP") xmlHttp.open "GET",strUrl,false xmlHttp.Send()'發送一個HTTP GET 請求 '當返回的Http狀態為200即表示請求資料成功 if xmlHttp.status=200 then '建立DOMDocument對象 Set xmlDoc = Server.CreateObject("Msxml2.DOMDocument") xmlDoc.async = False xmlDoc.Load (xmlHttp.responseXML)'裝載伺服器端返回的XML If xmlDoc.parseError.errorcode <> 0 Then GetMyICListForHtml="錯誤資訊:" & xmlDoc.parseError.reason Exit Function else 'response.Write xmlDoc.xml if xmlDoc.documentElement.childNodes.length=0 then strResult="沒有記錄" else strResult=xmlDoc.documentElement.childNodes.Item(0).text end if end if '當返回的Http狀態不為200時 else GetMyICListForHtml="下面是伺服器端返回的錯誤資訊,可能是你所發送的strData不正確所導致:
Http Status:" & xmlHttp.status & "
Http Status Text:" & xmlHttp.statusText & "
" Exit Function end if if err.number<>0 then GetMyICListForHtml="錯誤資訊:" & err.Description err.Clear() else GetMyICListForHtml=strResult end if End Function

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.