|
这是我的第一个android程序:helloword,我是在苹果机的模拟器上运行的,我想要连接到一个.NET
web服务器上,但是在connection.getOutputStream()发生exception,我可以从模拟器进到那个位置
有什么建议吗? URL url = new URL("http://192.168.3.47/service.asmx");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("OST");
connection.setRequestProperty("Content-Type",
"application/soap+xml; charset=utf-8");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
String soapRequest = String.format(getText(R.string.ws_listemain_ds_new).toString(),
city, keyword);
connection.setRequestProperty("Content-Length", Integer.toString(soapRequest.getBytes
("UTF-8").length));
//Send request
OutputStreamWriter owr = new OutputStreamWriter(connection.getOutputStream(), "UTF-
8");
[/code]03-02 15:51:26.950: WARN/System.err(618): java.net.SocketException: Permission denied
03-02 15:51:26.978: WARN/System.err(618): at
org.apache.harmony.luni.platform.OSNetworkSystem.socket(Native Method)
03-02 15:51:26.988: WARN/System.err(618): at dalvik.system.BlockGuard
$WrappedNetworkSystem.socket(BlockGuard.java:335)
03-02 15:51:27.009: WARN/System.err(618): at
org.apache.harmony.luni.net.PlainSocketImpl.create(PlainSocketImpl.java:216)
03-02 15:51:27.018: WARN/System.err(618): at java.net.Socket.checkOpenAndCreate
(Socket.java:802)
03-02 15:51:27.037: WARN/System.err(618): at java.net.Socket.connect(Socket.java:948)
03-02 15:51:27.048: WARN/System.err(618): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.
(HttpConnection.java:75)
03-02 15:51:27.067: WARN/System.err(618): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.
(HttpConnection.java:48)
03-02 15:51:27.079: WARN/System.err(618): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect
(HttpConnection.java:322)
03-02 15:51:27.139: WARN/System.err(618): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get
(HttpConnectionPool.java:89)
03-02 15:51:27.158: WARN/System.err(618): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnec
tion(HttpURLConnectionImpl.java:285)
03-02 15:51:27.167: WARN/System.err(618): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnectio
n(HttpURLConnectionImpl.java:267)
03-02 15:51:27.187: WARN/System.err(618): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect
(HttpURLConnectionImpl.java:205)
03-02 15:51:27.197: WARN/System.err(618): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getOutputStre
am(HttpURLConnectionImpl.java:614)
03-02 15:51:27.217: WARN/System.err(618): at gyozo.HelloWorld.HelloActivity.onClick
(HelloActivity.java:55)
03-02 15:51:27.269: WARN/System.err(618): at android.view.View.performClick
(View.java:2485)
03-02 15:51:27.311: WARN/System.err(618): at android.view.View$PerformClick.run
(View.java:9080)
03-02 15:51:27.327: WARN/System.err(618): at android.os.Handler.handleCallback
(Handler.java:587)
03-02 15:51:27.347: WARN/System.err(618): at android.os.Handler.dispatchMessage
(Handler.java:92)
03-02 15:51:27.367: WARN/System.err(618): at android.os.Looper.loop(Looper.java:123)
03-02 15:51:27.447: WARN/System.err(618): at android.app.ActivityThread.main
(ActivityThread.java:3683)
03-02 15:51:27.457: WARN/System.err(618): at java.lang.reflect.Method.invokeNative
(Native Method)
03-02 15:51:27.519: WARN/System.err(618): at java.lang.reflect.Method.invoke
(Method.java:507)
03-02 15:51:27.527: WARN/System.err(618): at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-02 15:51:27.547: WARN/System.err(618): at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:597)
03-02 15:51:27.547: WARN/System.err(618): at dalvik.system.NativeStart.main(Native
Method)
[/code]
我来回答 |
|