2013-03-28 104 views
-1

我有一个工作任务,使用Web服务,使基于经典Asp的网站之间的通信基于Android平台的应用程序,以创建函数与参数日期,从中提供数据BD,我没有任何想法如何开始,你可以给我一个例子或教程遵循?Web服务&经典Asp

回答

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

+0

谢谢你,我做了一个研究,我没有找到在谷歌:(需要任何tutoriel一些帮助:■ –

+0

要创建“Web服务”,在服务器上创建一个类似于我上面展示的ASP页面,为了“产生”JSON输出,“包含”并使用在线发现的许多库中的一个,我编辑了我的答案 - 参考一个 - 检查它的SQL例如 –

+0

非常感谢:) –