【发布时间】:2013-01-09 11:40:21
【问题描述】:
我正在使用 .net webservice 来捕获我从 Android 应用程序获得的响应。 我从 android 应用程序返回以下行
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"http://10.0.2.2:51889/OMS/WebServices/Service.asmx/Test");
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
nameValuePair.add(new BasicNameValuePair("email", "abc"));
nameValuePair.add(new BasicNameValuePair("pwd", "123"));
// Url Encoding the POST parameters
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
} catch (UnsupportedEncodingException e) {
// writing error to Log
e.printStackTrace();
}
// Making HTTP Request
try {
HttpResponse response = httpClient.execute(httpPost);
} catch (ClientProtocolException e) {
// writing exception to log
e.printStackTrace();
} catch (IOException e) {
// writing exception to log
e.printStackTrace();
}
如何在 .net 网络服务中得到响应?
我从android得到这样的数据
那么我如何在 C#.net 中获取这些数据???
【问题讨论】:
-
.net webservice 来捕获响应或请求??应该是请求。
-
不,这是来自android应用程序的响应返回..
-
来自 Anroid 应用程序的响应???您是在应用程序中运行 HTTP 服务器还是如何从 .net 应用程序调用到 android 应用程序?据我所知,您正在从 android 向服务器发出 HTTP POST?
-
啊,好吧,这对你来说可能是正确的:msdn.microsoft.com/en-us/library/dd203052.aspx
-
我知道这是一个旧线程。试试这个 [链接][1] 它可能会有所帮助。 [1]:stackoverflow.com/questions/4088625/…
标签: c# android web-services post http-post