Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从android throw web服务WCf连接sql server_Java_Android_Sql Server_Wcf_Web Services - Fatal编程技术网

Java 从android throw web服务WCf连接sql server

Java 从android throw web服务WCf连接sql server,java,android,sql-server,wcf,web-services,Java,Android,Sql Server,Wcf,Web Services,我花了很多时间连接本地数据库jdbcOdbcDrivr。很多人建议我从android应用程序web服务连接数据库。WCF是制作web服务的伟大解决方案,我这样做并将web服务发布到本地IIS服务器 当我使用直接 url 192.168.0.1:90/Service1.svc/checkLogin?name=a&pass=1 它很好用 当我使用andriod应用程序时 HttpGet httpGet=new HttpGet( "192.168.0.1:90/Service1.sv

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

当我使用直接

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); 
它不起作用

请告诉我如何解决此问题

在以下内容之前添加:“http://”:192.168.0.1:90/Service1.svc/checkLogin?name='“+UserName+”&pass='+Password

因此,您将有:

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

注意:如果您使用的是android emulator,并且您的web服务正在本地IIS服务器上运行,则必须将您的ip主机添加到android主机文件中,请查看此

HttpGet-HttpGet=new-HttpGet(“);HttpResponse HttpResponse=httpClient.execute(httpGet);当我调试我的应用程序时,当它到达以下行HttpResponse HttpResponse=httpClient.execute(httpGet)时,它将捕获(异常e){return false;};错误是org.apache.http.conn.HttpHostConnectException:Connection to refused在android中编码时不要使用localhost。因为android本身使用本地主机。而是使用ip地址。并在ip地址之前添加http://当我使用ip地址时,它会转到异常处理,这是详细信息:“未能连接到/192.168.112.134(端口90):连接失败:ETIMEDOUT(连接超时)org.apache.http.conn.HttpHostConnectException:Connection to refusedPlease能帮我什么忙吗?我不使用Emulatory来运行我的android应用程序,然后看看你是否可以使用ip主机,如10.0.2.2或10.0.0.2,这与在计算机中使用的127.0.0.1相同。