【发布时间】:2011-08-02 00:08:11
【问题描述】:
我正在尝试在 Android 模拟器上编写一个 java 代码,它将一个字符串发送到一个用 c# 编写的 Web 服务。
安卓代码:
HttpPost httppost = new HttpPost("http://192.168.2.1:53811/WinnerSite/WebService.asm/MyMethod
尝试 {
// 添加你的数据
列表名称ValuePairs = new ArrayList(2);
nameValuePairs.add(new BasicNameValuePair("json", name));
// nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev 很酷!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// 执行 HTTP Post 请求
HttpResponse 响应 = httpclient.execute(httppost);
也试过了:
HttpPost httppost = new HttpPost("http://192.168.2.1:53811/WinnerSite/WebService.asm/MyMethod网络服务与模拟器在同一台机器上。 MyMethod 可通过以下方式访问:
http://localhost:53811/WinnerSite/WebService.asmx/MyMethod有人有想法吗?
代码在“httpclient.execute(httppost);”上退出线
日食显示:
"ActivityThread.prefo
Source not found."
我已经解决了一个权限问题(在 emolator 的 xml 中添加注释)
谢谢,
【问题讨论】:
-
我不清楚你的问题是什么。您在运行应用程序或构建应用程序时遇到某种错误? “日食显示……”非常模糊。您能否发布完整的错误并解释您在哪个阶段看到它?