我使用的是Client Server Application .Client是Ubuntu平台上的Android设备。我的服务器是IIS,即MS Visual Studio 2010.两个系统(Ubuntu-Where Android Aap正在开发,Window7-Where服务器所在位置)通过WI-FI连接。我得到了一个例外
03-29 09:56:54.141: I/System.out(576): Place order click
03-29 09:56:54.262: I/System.out(576): address = http://192.168.1.3/RestaurantPOSNew/ProcessOrder.aspx?order_id=3&table_no=11&order_items=%5B%7B%22OrderID%22%3A3%2C%22isAdd%22%3Atrue%2C%22itemId%22%3A2%2C%22quantity%22%3A4%7D%2C%7B%22OrderID%22%3A0%2C%22isAdd%22%3Afalse%2C%22itemId%22%3A0%2C%22quantity%22%3A0%7D%5D
03-29 09:56:59.382: I/dalvikvm(576): threadid=4: reacting to signal 3
03-29 09:56:59.412: I/dalvikvm(576): Wrote stack traces to '/data/anr/traces.txt'
03-29 09:57:15.271: W/System.err(576): org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.3 refused
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
03-29 09:57:15.312: W/System.err(576): at com.sst.restaurant.RestaurantHome.sendJSONOrderToServer(RestaurantHome.java:1480)
03-29 09:57:15.322: W/System.err(576): at com.sst.restaurant.RestaurantHome$8.onClick(RestaurantHome.java:1172)
03-29 09:57:15.322: W/System.err(576): at android.view.View.performClick(View.java:3110)
03-29 09:57:15.322: W/System.err(576): at android.view.View$PerformClick.run(View.java:11928)
03-29 09:57:15.322: W/System.err(576): at android.os.Handler.handleCallback(Handler.java:587)
03-29 09:57:15.322: W/System.err(576): at android.os.Handler.dispatchMessage(Handler.java:92)
03-29 09:57:15.322: W/System.err(576): at android.os.Looper.loop(Looper.java:132)
03-29 09:57:15.322: W/System.err(576): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-29 09:57:15.322: W/System.err(576): at java.lang.reflect.Method.invokeNative(Native Method)
03-29 09:57:15.322: W/System.err(576): at java.lang.reflect.Method.invoke(Method.java:491)
03-29 09:57:15.322: W/System.err(576): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-29 09:57:15.322: W/System.err(576): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-29 09:57:15.332: W/System.err(576): at dalvik.system.NativeStart.main(Native Method)
03-29 09:57:15.342: W/System.err(576): Caused by: java.net.ConnectException: /192.168.1.3:80 - Connection refused
03-29 09:57:15.342: W/System.err(576): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:211)
03-29 09:57:15.352: W/System.err(576): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:431)
03-29 09:57:15.352: W/System.err(576): at java.net.Socket.connect(Socket.java:901)
03-29 09:57:15.352: W/System.err(576): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
03-29 09:57:15.352: W/System.err(576): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
03-29 09:57:15.362: W/System.err(576): ... 19 more
03-29 09:57:15.393: I/System.out(576): inside handler
03-29 09:57:15.691: D/dalvikvm(576): GC_CONCURRENT freed 844K, 11% free 10643K/11847K, paused 8ms+65ms
我在清单文件中声明了互联网权限。我通过终端中的ping命令检查了两个系统都在同一个网络中。