views:

2384

answers:

3

Hay, I'm taying to make a simple Rest web service in C# and client on android. I find a simple C# web service, which add two number, on this link:

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

Can anyone help me to make Android client for this web service

Thanks

A: 

See my question here: http://stackoverflow.com/questions/992880/unresolved-host-exception-android

Calling the rest service is just a matter of creating the HttpResponse and processing the returned xml/json/value.

Rob Stevenson-Leggett
Thanks you for reply on this question.I wonder can you send me full example, lake some easy project.My maili is: [email protected]
Milos
If only getting the something done was that simple...
ing0
A: 

Hi milos, i also want the REST service client in androids culd u plz help me out?

Best Regards, Faheem [email protected]

Faheem Akbar Sial
Dude do you want to be trolled. take your email address out.
uriDium
+2  A: 

Hi, you probably found something that works, but i stumbled accross this thread, and for others, following can be useful.

I prefer REST application using with MVC and Android. -www.asp.net/mvc (good video-tutorials)

To create a Server:

h t t p : / / omaralzabir.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'/>");
    }
}

And set Global.asax:

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

Andoid Client development code exampels:

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 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);

Tips about designing REST for Android:

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

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

General Android help:

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

Per G