android - C# Rest Web 服务和 Android 客户端

标签 android web-services rest

嘿,我打算用 C# 创建一个简单的 Rest Web 服务,在 android 上创建一个客户端。 我在这个链接上找到了一个简单的 C# web 服务,它添加了两个数字:

http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/RESTEnabledService05122009034907AM/RESTEnabledService.aspx

谁能帮我为这个网络服务制作安卓客户端

谢谢

最佳答案

您可能找到了一些有用的东西,但我偶然发现了这个线程,对于其他人来说,以下内容可能会有用。

我更喜欢使用 MVC 和 Android 的 REST 应用程序。 -www.asp.net/mvc(很好的视频教程)

创建服务器:

h t t p :// omalzabir.com/create_rest_api_using_asp_net_mvc_that_speaks_both_json_and_plain_xml/

public class TestingController : Controller {
    /// <summary>
    /// Test
    /// </summary>
    /// <returns></returns>
    public ActionResult GetString() {
        return Content("A Result <orasxml id='testid'/>");
    }
}

并设置 Global.asax:

//测试 routes.MapRoute("test", "{Page}.Mvc/tester", new { controller = "Testing", action = "GetString", Page = defaultPage });

Android客户端开发代码示例:

http://www.smnirven.com/?p=15

h t t p ://senior.ceng.metu.edu.tr/2009/praeda/2009/01/11/a-simple-restful-client-at-android/

公共(public)字符串 GetData(){

    //Note, do not use http:// in host name. I did not get localhost-adress working, but
    //hosted a page in IIS instead, and it worked.
    HttpHost target = new HttpHost("www.example,com",80);
    HttpGet get = new HttpGet("/tester");
    String result=null;
    HttpEntity entity = null;
    HttpClient client = new DefaultHttpClient();
    try {
        HttpResponse response=client.execute(target, get);
        entity = response.getEntity();
        result = EntityUtils.toString(entity);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
    if (entity!=null)
    try {
        entity.consumeContent();
    } catch (IOException e) {}
    }
    return result;

    //Display on buttontext, must create buttoon with ButtonReload as id...
    final Button btn = (Button) findViewById(R.id.ButtonReload);
    btn.setText(testString);

有关为 Android 设计 REST 的提示:

h t t p ://www.youtube.com/watch?v=xHXn3Kg2IQE

h t t p ://www.infoq.com/articles/rest-introduction

一般 Android 帮助:

h t t p ://mobile.tutsplus.com/tutorials/android/introduction-to-android-development/

h t t p ://www.youtube.com/watch?v=lqopIf-bA54&feature=related

关于android - C# Rest Web 服务和 Android 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1193054/

相关文章:

android - URI 未注册 Android studio 错误

android - ionic 闪屏尺寸

asp.net - Azure - Web 服务角色可以支持多少用户?

PHP 且无 Soap 操作 header

ruby-on-rails-3 - 将一个实体添加到另一个实体的 RESTful 方式(n :m relation) in Rails 3?

node.js - Mongoose - REST API - 查询不同模型的模式

rest - Delphi - 将 header 值传递给 REST 服务

android - Nexus 7 Chrome 上计算的字体大小与 CSS 字体大小不同

iphone - 在 Objective-C (iPhone) 中使用 SVC 网络服务

android - 调用 TextInputLayout 的 setError() 时,不要将提示移动到顶部