本文介绍了尝试将字符串从Android模拟器发送到Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Android模拟器上编写Java代码,该代码会将字符串发送到用C#编写的Web服务.
Android代码:
Hi,
I''m trying to write a java code on an Android emulator that will send a string to a web service writen in c#.
Android code:
HttpPost httppost = new HttpPost("http://192.168.2.1:53811/WinnerSite/WebService.asm/MyMethod
try {
// Add your data
List<namevaluepair> nameValuePairs = new ArrayList<namevaluepair>(2);
nameValuePairs.add(new BasicNameValuePair("json", name));
// nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
</namevaluepair></namevaluepair>
也尝试过:
Also tried:
HttpPost httppost = new HttpPost("http://192.168.2.1:53811/WinnerSite/WebService.asm/MyMethod
Web服务与仿真器位于同一台计算机上.可通过以下方式访问MyMethod:
The web-service is on the same machine as the emulator. MyMethod is accessable through:
http://localhost:53811/WinnerSite/WebService.asmx/MyMethod
有人问我一个主意吗?
该代码在"httpclient.execute(httppost);"上退出.线
月食显示:
Does someine ahs an idea?
The code exits on the "httpclient.execute(httppost);" line
The eclipse shows:
"ActivityThread.prefo<br />
Source not found."<br />
我已经解决了权限问题(在emolator的xml中添加了注释)
谢谢,
I have already solve a persmission problem (adding a note to the emolator''s xml)
Thanks,
推荐答案
这篇关于尝试将字符串从Android模拟器发送到Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!