当前位置:  开发笔记 > 编程语言 > 正文

C#Rest Web服务和Android客户端

如何解决《C#RestWeb服务和Android客户端》经验,为你挑选了1个好方法。

Hay,我想在C#中创建一个简单的Rest Web服务,在android上创建客户端.我在这个链接上找到了一个简单的C#Web服务,它添加了两个数字:

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

任何人都可以帮助我为这个Web服务制作Android客户端

谢谢



1> Per G..:

你可能找到了一些有用的东西,但我偶然发现了这个帖子,而对于其他人来说,以下内容可能很有用.

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

要创建服务器:

http://omaralzabir.com/create_rest_api_using_asp_net_mvc_that_speaks_both_json_and_plain_xml/

public class TestingController : Controller {
    /// 
    /// Test
    /// 
    /// 
    public ActionResult GetString() {
        return Content("A Result ");
    }
}

并设置Global.asax:

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

Andoid客户端开发代码示例:

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

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

public String 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的提示:

http:/ /www.youtube.com/watch?v=xHXn3Kg2IQE

http:/ /www.infoq.com/articles/rest-introduction

一般Android帮助:

http://mobile.tutsplus.com/tutorials/android/introduction-to-android-development/

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

推荐阅读
赛亚兔备_393
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有