Android应用程序和asp.net C#之间的数据传输 [英] data transfer between android app and asp.net C#

查看:375
本文介绍了Android应用程序和asp.net C#之间的数据传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的Andr​​oid应用程序将数据发送到asp.net(C#),在C#页面,我会从Android应用程序接收到的数据进行一些数据库操作,之后我会送回来,结果我的android应用。

I want to send data from my android application to asp.net(c#).In C# page i will perform some database operations on the data received from android app and after that I will send back the results to my android application.

我没有怎么办this.Please谁能解释或给一些example.I的链接任何想法已经搜索了很多,但没能找到合适的answer.So请解释每一个步骤要遵循或引用一些链接的例子。

I don't have any idea of how to do this.Please anyone explain or give the link of some example.I have searched a lot but was not able to find the right answer.So please explain each step to follow or quote some links for examples.

推荐答案

我建议你看看这个,从的 MSDN

I suggest you take a look at this, from MSDN:

Windows通讯基础(WCF)是用于构建面向服务的应用程序的框架。使用WCF,您可以从一个服务端点发送数据的异步消息到另一个。服务端点可以通过IIS托管的连续可用服务的一部分,也可以是在应用程序中承载的服务。

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.

退房的链接的详细信息,以及谷歌的 WCF 。我将无法在这个答案来解释一切,但我会为你提供指导方针。

Check out the link for more information, and google for WCF. I won't be able to explain everything in this answer, but I'll provide you the guidelines.

您可以承载您的WCF服务,并通过HTTP(或任何协议,您可以使用)访问它。在你的Andr​​oid,以方便你可以使用一个库,如 KSOAP 。您可以检查一些SO问题为好, KSOAP ANDROID实施,的Getting~~V~~aux入门KSOAP在Android

You can host your WCF service, and access it through HTTP (or whatever protocol you can use) . In your android, to make it easy you can use a library such as KSOAP. You can check some SO questions as well, KSOAP ANDROID Implementation , Getting Started with KSOAP on Android.

现在,现在,如果你在谈论你的Andr​​oid打开一个页面来处理的东西,你可以发布的信息给它,并得到响应回来处理它。

Now, now, if you're talking about opening a page in your android to process something, you can just post information to it, and get the response back and process it.

在第二种情况下,我认为你可以使用的HttpClient HttpPost 类,从
org.apache.http.client 包。什么东西在这些行:

In this second case, I think you can use HttpClient and HttpPost classes, from org.apache.http.client package. Something in these lines:

HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://www.myaspnetstuff.com/process");

try {
    List<NameValuePair> parameters = new ArrayList<NameValuePair>(1);
    parameters.add(new BasicNameValuePair("id", "1"));

    httpPost.setEntity(new UrlEncodedFormEntity(parameters));

    //here you get your response and do whatever fits your needs.
    HttpResponse response = httpClient.execute(httpPost);

} catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
} catch (IOException e) {
    // TODO Auto-generated catch block
}

这篇关于Android应用程序和asp.net C#之间的数据传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆