国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 房山区| 恭城| 和平县| 大关县| 新巴尔虎左旗| 眉山市| 封开县| 承德县| 兰坪| 囊谦县| 道孚县| 洮南市| 雷波县| 东辽县| 浦城县| 津南区| 沛县| 临清市| 郑州市| 谷城县| 漯河市| 鄂托克前旗| 杨浦区| 铁力市| 碌曲县| 谷城县| 德庆县| 中超| 贵定县| 磐石市| 西昌市| 开原市| 碌曲县| 常德市| 石泉县| 饶河县| 西峡县| 十堰市| 休宁县| 河东区| 乐安县|