2013-10-05 182 views
0

我花了很多时间连接本地数据库抛出jdbcOdbcDrivr。许多人建议我从android应用程序抛出web服务连接数据库。 WCF是制作Web服务的绝佳解决方案,我这样做并将Web服务发布到本地IIS服务器。从android连接到sql服务器抛出web服务WCf

当我使用直接

url 192.168.0.1:90/Service1.svc/checkLogin?name=a&pass=1 

它工作正常。

当我的Andriod应用

HttpGet httpGet=new HttpGet(
    "192.168.0.1:90/Service1.svc/checkLogin?name='"+UserName+"'&pass='"+Password); 

使用它没有工作。

请告诉我能做些什么来解决这个问题

回答

0

有关添加方法如下:“HTTP://”在此之前:192.168.0.1:90/Service1.svc/checkLogin?name='"+UserName+” “&通=”“+密码

所以你必须:

http://192.168.0.1:90/Service1.svc/checkLogin?name='"+UserName+"'&pass='"+Password 
+0

HttpGet httpGet = new HttpGet(“http://192.168.0.1:90/Service1.svc/checkLogin?name='”+ UserName +“'&pass ='”+ Password); \t HttpResponse httpResponse = httpClient.execute(httpGet); 当我调试我的应用程序,这是去 赶上(例外五) \t { \t \t返回FALSE; \t} 当它来到这些行 HttpResponse httpResponse = httpClient.execute(httpGet); – user2839125

+0

错误是org.apache.http.conn.HttpHostConnectException:连接到http:// localhost:90拒绝 – user2839125

+0

在android中编码时不使用localhost。因为android本身使用localhost。而是使用IP地址。并添加http://之前的IP地址 –

0

注意,如果你使用的是Android模拟器,以及您的网络服务在本地IIS服务器上运行,则必须添加IP主机到你的android主机文件看看这个http://mcilvena.com/articles/modify-android-host-file/

+0

Iam不使用emulatour运行我的android应用程序 – user2839125

+0

然后看看你是否可以使用,像10.0.2.2或10.0.0.2这样的IP主机,当在计算机中使用时,它与127.0.0.1相同。 – xhamr

+0

不能正常使用localHost或127.0.0.1 – user2839125