网络服务&经典的Asp

时间:2013-03-28 18:26:47

标签: service web asp-classic

我正在使用网络服务开展工作,在基于Classic Asp& A的网站之间进行通信。一个基于android平台的应用程序,创建一个带有参数Date的函数,它提供了来自bd的数据,我不知道如何处理,你能不能给我一个例子或tutos跟随?

1 个答案:

答案 0 :(得分:2)

你最简单的选择就是生成json(很容易被android方面使用),如下所示:

ASP“服务”

<!-- 
this is one example of a library of json helpers that you can use. 
You can get it from this page
http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/
http://www.webdevbros.net/wp-content/uploads/2008/07/json151.zip
save the downloaded json.asp file in the same folder as your .asp 
-->

<!--#include file="json.asp" -->

<%
    REM 1. Create and populate ADO Recordset from database
    REM   Note: I am providing just an example and you might 
    REM   ant to look into using a more appropriate command type 
    REM   or cursor type when populating your recordset        

    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open "put your connection string here"
    Set cmd = Server.CreateObject("ADODB.Command")
    cmd.CommandType = adCmdText 'note must have this constant defined in scope'
    Set cmdTemp.ActiveConnection = conn

    cmd.CommandText = "put your SQL here; be careful to protect against SQL injections" 

    Set rs = Server.CreateObject("ADODB.Recordset")

    rs.Open cmd, ,adOpenForwardOnly,adLockReadOnly 'note make sure these constants are defined in scope'

    REM 2. Prepare json
    Dim jsonObject

    Set jsonObject = New JSON   'JSON class is in the include file json.asp'
    jsonResult = jsonObject.toJSON(Empty, rs, False) 'You may have to play with the parameters here, if the way json is formatted does not suit you'
                                                   'check the documentation of json.asp library'

    REM 3. stream json to client
    Response.ContentType = "application/json" 
    Response.Write jsonResult
%>

您可以找到更多有助于将值或结构格式化为JSON的库:只需在SO或Google上搜索“经典ASP”+ JSON即可。 Here's one library采用vbscript / ASP结构并以JSON格式输出。看一下SQL示例。

检查此SO thread以获取更多“经典”ASP和JSON