簡體   English   中英

Android Rest Asp.net Web服務?

[英]Android Rest Asp.net Web Services?

我是android的新手,我想在我的android應用中使用asp.net webservices。 但我不知道該怎么用?

我想使用Restful method.But,但是當我在google中搜索時,我發現了所有使用Soap的教程。 是對asp.net強制使用肥皂還是有其他可用選項,我們可以在android中對asp.net使用其余選項。

我已經按照本教程。 鏈接

您可以隨時使用JSON。

Json是跨網絡最快的數據傳輸模式,因此您的Web服務應以Json格式返回數據。

一旦有了Json,您就可以隨時對其進行渲染並根據需要使用它。

這是呈現數據的示例http://www.tutorialspoint.com/android/android_android_json_parser.htm

您可以創建WCF REST Web服務

http://msdn.microsoft.com/zh-CN/library/ms731082(v=vs.110).aspx

或更簡單的方法是創建一個新的MVC4 Web應用程序,並更新Controller以擴展Api Controller,然后創建一個新的Web方法,該方法將返回HttpResponseMessasge,如下所示:

public class MyController : ApiController
{
    public HttpResponseMessage MyWebMethod()
    {
        HttpContext.Current.Response.ContentType = "text/plain";

        HttpContext.Current.Response.Write([WRITE YOUR JSON HERE]);

        return new HttpResponseMessage(HttpStatusCode.OK);
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM