2014-01-07 35 views
0

当我尝试通过webservice提交请求时,出现以下异常。在web服务中获取连接超时例外

的堆栈跟踪如下:

Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection timed out: connect 
    at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:117) 
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:194) 
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:122) 
    at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:95) 
    at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:626) 
    at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:585) 
    at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:570) 
    at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:467) 
    at com.sun.xml.internal.ws.client.Stub.process(Stub.java:308) 
    at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:146) 
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98) 
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78) 
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:129) 
    at $Proxy40.externalSearchPerson(Unknown Source) 
    at com.igniteibroker.Main.personSearch(Main.java:52) 
    at com.igniteibroker.Main.main(Main.java:64) 
Caused by: java.net.ConnectException: Connection timed out: connect 
    at java.net.DualStackPlainSocketImpl.connect0(Native Method) 
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69) 
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) 
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) 
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) 
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) 
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) 
    at java.net.Socket.connect(Socket.java:579) 
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618) 
    at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:160) 
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180) 
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:378) 
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:473) 
    at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:270) 
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:327) 
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) 
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:974) 
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) 
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1090) 
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250) 
    at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:105) 
    ... 15 more 

请帮我解决这个,如果你已经确定的问题。在此先感谢

+1

您是否检查请求的URL是否可用?连接超时是由不可用的URI或慢速连接引起的。你能否检查你是否可以直接连接到所请求的URI(即使用网络浏览器)。 –

+0

嗨阿里HAMDI,我也遇到了同样的错误,当我尝试使用SoapUI工具。 并且可以完全排除网络问题 –

+0

然后,您必须检查Web服务的状态,它可能不可用或不可用。 –

回答

0

如果您正在使用jersey.api

import com.sun.jersey.api.client.Client; 
import com.sun.jersey.api.client.ClientResponse; 
import com.sun.jersey.api.client.WebResource; 
import com.sun.jersey.api.client.config.ClientConfig; 
import com.sun.jersey.api.client.config.DefaultClientConfig; 
import com.sun.jersey.api.representation.Form; 


ClientResponse response = null; 
ClientConfig config = new DefaultClientConfig(); 
Client client = Client.create(config); 
/*client.setReadTimeout(30);*/ 
/*client.setConnectTimeout(interval)*/ 
WebResource service = client.resource(getBaseURI()); 

在客户端类有方法client.setConnectTimeout(间隔)如果u没有设置这个方法,然后它会尝试进行连接无限的时间。

+0

嗨我有连接超时到2分钟。并且我使用javax.xml.ws.client.connectionTimeout“,”200000“ –

+0

基本上这个方法接受以毫秒为单位的值,如果分配null或0,那么自动它将会是无限减速的间隔。 –

0

我试图加载SoapUI中的WSDL文件。

令人惊讶的是给了我“java.lang.Exception: Failed to load url;

我认为你正在使用https wsdl url加载此webservice

它将被密码保护。在您的机器上本地保存您的wsdl文件并尝试在soap ui中加载wsdl文件而不是url。

在h ttps endpoint处发送请求时,您需要提供用户名和密码。
soapui您可以填写请求属性中的用户名和密码在左下角。