ksoap2问题java.net.ConnectException [英] ksoap2 issue java.net.ConnectException
问题描述
我使用kSoap2访问SOAP Web服务。我得到的 java.net.connectException 在执行下面的行
androidHttpTransport.call(Constants.SOAP_ACTION_GET_METHOD_NAME,信封)
这是不会发生总是,但一些时代。这是与连接时间的问题,外面的服务器?如何增加连接超时的KSOAP?我用Google搜索,但无法找出解决方案。 任何人都可以给我建议的解决方案来解决这个错误。
logcat的详细信息如下:
07-17 14:46:24.800:W / System.err的(8103):java.net.ConnectException:无法连接到www.yahoo.com/175.41.138.237( 80端口)后,20000:isConnected失败:ENETUNREACH(网络不可达)
07-17 14:46:24.800:W / System.err的(8103):在libcore.io.IoBridge.isConnected(IoBridge.java:214)
07-17 14:46:24.800:W / System.err的(8103):在libcore.io.IoBridge.connectErrno(IoBridge.java:152)
07-17 14:46:24.800:W / System.err的(8103):在libcore.io.IoBridge.connect(IoBridge.java:112)
07-17 14:46:24.800:W / System.err的(8103):在java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
07-17 14:46:24.800:W / System.err的(8103):在java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
07-17 14:46:24.800:W / System.err的(8103):在java.net.Socket.connect(Socket.java:842)
07-17 14:46:24.800:W / System.err的(8103):在libcore.net.http.HttpConnection< INIT>(HttpConnection.java:77)
07-17 14:46:24.800:W / System.err的(8103):在libcore.net.http.HttpConnection< INIT>(HttpConnection.java:50)
07-17 14:46:24.800:W / System.err的(8103):在libcore.net.http.HttpConnection $ Address.connect(HttpConnection.java:351)
07-17 14:46:24.800:W / System.err的(8103):在libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
07-17 14:46:24.810:W / System.err的(8103):在libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
07-17 14:46:24.810:W / System.err的(8103):在libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
07-17 14:46:24.810:W / System.err的(8103):在libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
07-17 14:46:24.810:W / System.err的(8103):在libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
07-17 14:46:24.810:W / System.err的(8103):在libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
07-17 14:46:24.810:W / System.err的(8103):在libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
07-17 14:46:24.810:W / System.err的(8103):在org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:80)
如何增加连接超时的KSOAP?
仍似乎有一个开放的问题, HttpTransportSE
忽略了在某些情况下超时值。
看到这个相关的链接一>
然而,这涉及修改解决现有的 ksoap2 API
。
由于开发商在 Lightsoftai 你现在可以加入超时 HttpTransportSE
使用以下code:
注意:您可以使用ksoap2 API版本2.5.2或更高此的
/ **
*创建HttpTransportSE实例与设定网址
*
* @参数的URL
*目的地为POST SOAP数据
* /
公共HttpTransportSE(字符串URL){
超(URL);
}
/ **
*创建HttpTransportSE实例与设定网址
*
* @参数的URL
*目的地为POST SOAP数据
* @参数超时
*超时连接和读取超时(毫秒)
* /
公共HttpTransportSE(字符串URL,INT超时){
超(URL,超时);
}
您可以从的这里。
另请参阅 KSOAP从不超时。
希望它帮助。
I am using kSoap2 for accessing soap web services. I am getting java.net.connectException while executing the below line
androidHttpTransport.call(Constants.SOAP_ACTION_GET_METHOD_NAME, envelope)
This is not happening always, but some of the times. Is this the problem with connection time out to the server? How to increase the connection time out in kSoap ? I googled, but can't find out the solution . Can anyone suggest me the solution to fix this error.
Logcat details follows:
07-17 14:46:24.800: W/System.err(8103): java.net.ConnectException: failed to connect to www.yahoo.com/175.41.138.237 (port 80) after 20000ms: isConnected failed: ENETUNREACH (Network is unreachable)
07-17 14:46:24.800: W/System.err(8103): at libcore.io.IoBridge.isConnected(IoBridge.java:214)
07-17 14:46:24.800: W/System.err(8103): at libcore.io.IoBridge.connectErrno(IoBridge.java:152)
07-17 14:46:24.800: W/System.err(8103): at libcore.io.IoBridge.connect(IoBridge.java:112)
07-17 14:46:24.800: W/System.err(8103): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
07-17 14:46:24.800: W/System.err(8103): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
07-17 14:46:24.800: W/System.err(8103): at java.net.Socket.connect(Socket.java:842)
07-17 14:46:24.800: W/System.err(8103): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:77)
07-17 14:46:24.800: W/System.err(8103): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
07-17 14:46:24.800: W/System.err(8103): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
07-17 14:46:24.800: W/System.err(8103): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
07-17 14:46:24.810: W/System.err(8103): at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:80)
How to increase the connection time out in kSoap ?
There still seems to be an open issue with HttpTransportSE
ignoring the timeout value in some situations.
See this related link.
However, a solution for this involved modification of the existing ksoap2 API
.
Thanks to the developers at Lightsoftai you can now add timeout to HttpTransportSE
using the following code:
Note : You can use ksoap2 API version 2.5.2 or greater for this
/**
* Creates instance of HttpTransportSE with set url
*
* @param url
* the destination to POST SOAP data
*/
public HttpTransportSE(String url) {
super(url);
}
/**
* Creates instance of HttpTransportSE with set url
*
* @param url
* the destination to POST SOAP data
* @param timeout
* timeout for connection and Read Timeouts (milliseconds)
*/
public HttpTransportSE(String url, int timeout) {
super(url, timeout);
}
You can download the jar file for the same from here.
Also refer ksoap never timeout.
Hope it helps.
这篇关于ksoap2问题java.net.ConnectException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!