国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

使用HTTPService與Asp的偽Web服務(wù)通訊,完成數(shù)據(jù)庫操作

2024-05-04 11:06:39
字體:
供稿:網(wǎng)友
使用httpservice與asp的偽web服務(wù)通訊,完成數(shù)據(jù)庫操作

我提供一個(gè)asp的偽服務(wù)思想:

clientreq.xml:
-------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="gb2312"?>
<testpacket>
<msgtype>getvaluereq</msgtype>
<version>1.0</version>
</testpacket>


index.mxml:
-------------------------------------------------------------------------------------------------
<mx:model id="mreq" source="clientreq.xml"/>
<mx:httpservice id="hs" url="http://asp/testserver.asp"
resultformat="xml"
method="post"
contenttype="application/xml"
showbusycursor="true">
<mx:request>
<xml>{mreq}</xml>
</mx:request>
</mx:httpservice>


testserver.asp:
-------------------------------------------------------------------------------------------------
主要有獲得數(shù)據(jù)包,解析數(shù)據(jù)包,指定操作,返回?cái)?shù)據(jù)四步

1。獲得提交的數(shù)據(jù)包
set odom = server.createobject("msxml2.domdocument")
odom.load request

2。解析數(shù)據(jù)包,獲得msgtype
smsgtype = trim(odom.selectsinglenode("//msgtype").text)
select case smsgtype
case "getvaluereq"
call getvalue
'case "deletevaluereq"
' call deletevalue
case "insertvaluereq"
' call insertvalue(odom)
'case "updatevaluereq"
' call updatevalue
'else case
' call showerrmsg
end select

3。指定操作,此處完成getvalue操作,其中有很多可以做成公共的模塊供其他函數(shù)使用
sconn = "driver={microsoft access driver (*.mdb)};dbq=" & server.mappath("message.mdb")
set oconn = server.createobject("adodb.connection")
oconn.open sconn
ssql = "select * from message order by id desc"
set ors = server.createobject("adodb.recordset")
ors.open ssql, oconn, 1, 1

'構(gòu)造無記錄xml文檔
if ors.eof and ors.bof then
sxml = "<?xml version=""1.0"" encoding=""gb2312""?>" & vbcrlf &_
"<testpacket>" & vbcrlf &_
" <msgtype>systemresp</msgtype>" & vbcrlf &_
" <version>1.0</version>" & vbcrlf &_
" <result>0</result>" & vbcrlf &_
"</testpacket>"
end if

'構(gòu)造有記錄xml文檔
if not (ors.eof and ors.bof) then
do while not ors.eof
stmpxml = stmpxml & "<messages>" & vbcrlf &_
"<name>" & ors("name") & "</name>" & vbcrlf &_
"<age>" & ors("age") & "</age>" & vbcrlf &_
"<sex>" & ors("sex") & "</sex>" & vbcrlf &_
"<msg>" & ors("msg") & "</msg>" & vbcrlf &_
"</messages>" & vbcrlf
ors.movenext
loop
sxml = "<?xml version=""1.0"" encoding=""gb2312""?>" & vbcrlf &_
"<testpacket>" & vbcrlf &_
" <msgtype>systemresp</msgtype>" & vbcrlf &_
" <version>1.0</version>" & vbcrlf &_
" <result>1</result>" & vbcrlf & stmpxml &_
"</testpacket>"
end if

4.返回?cái)?shù)據(jù)
set odom = server.createobject("msxml2.domdocument")
odom.loadxml(sxml)
odom.save(response)
set odom = nothing


message.mdb
-------------------------------------------------------------------------------------------------
數(shù)據(jù)庫名:message.mdb
數(shù)據(jù)表名:message
數(shù)據(jù)字段:字段 類型
id 自動(dòng)編號(hào)
name 文本
age 數(shù)字
sex 文本
msg 備注


執(zhí)行結(jié)果:
-------------------------------------------------------------------------------------------------
我是設(shè)置httpservice的resultformat="text"時(shí),看顯示的結(jié)果



本主題包含附件: sf_2004111813537.jpg (23359bytes)







csdn blog: http://blog.csdn.net/stefli

stefli's mp3: http://stefli.88ip.net/flex/mp3player.swf


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 石楼县| 牡丹江市| 巴塘县| 郴州市| 上犹县| 溧水县| 任丘市| 宜州市| 图木舒克市| 南宁市| 子洲县| 巴马| 黑山县| 晋江市| 兴隆县| 麟游县| 加查县| 呈贡县| 重庆市| 高陵县| 海城市| 彭山县| 双辽市| 皮山县| 舒兰市| 图们市| 吴川市| 新平| 乌拉特后旗| 公安县| 隆回县| 海丰县| 长宁区| 定襄县| 伊通| 永吉县| 定南县| 德阳市| 聂荣县| 左云县| 昌邑市|