使用http在Android上调用我的Apache Web服务 [英] using http to invoke my apache webservice on android

查看:91
本文介绍了使用http在Android上调用我的Apache Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Android应用程序,该应用程序允许用户通过我的tomcat网络服务在数据库上创建帐户。我已经使用浏览器测试了网络服务,并且运行正常。因此,我尝试在我的andriod应用程序中使用对该URL发出Http请求,但无法正常工作。

I'm working on an android application which allows users to create accounts on a database via my tomcat webservice. I've tested the webservice with a browser and it works fine. So I've tried to use make Http requests to that URL with my andriod app but it doesn't work.

这是我的代码

try{

        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        URI webservice = new URI("http://my-machine-ip:8080/Login/login?username=jimmy&password=javajava");
        request.setURI(webservice);
        HttpResponse response = client.execute(request);            
    }catch (Exception e1) {
        e1.printStackTrace();
    }

我还设置了互联网许可。 <使用权限android:name = android.permission.INTERNET />

I have also set the internet permission. <uses-permission android:name="android.permission.INTERNET" />

检查我的日志我有连接错误

Checking my log I have a connection error

05-31 17:46:50.299: W/System.err(17395): org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.0.3:8080 timed out

enter code here


推荐答案

显然,这是导致我的防火墙出现连接问题的原因。快速重新配置具有防火墙访问权限的应用程序已解决了所有问题

Apparently, this was a connection problem caused my my firewall. A quick reconfiguration of applications with access on the firewall has solved everything

这篇关于使用http在Android上调用我的Apache Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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