Soap Connection timed out in Java client but not in SOAPUI

不羁的心 提交于 2019-12-12 19:19:20

问题


I created a soap client with wsimport and a given wsdl. I also used SoapUI to test the service. Using SoapUI I had no problem but when using my Java client I get

java.net.ConnectException: Connection timed out: connect

The default values I have in the requestContext are as follows

com.sun.xml.internal.ws.connect.timeout=100000
javax.xml.ws.service.endpoint.address=[fully qualified domain name endpoint]
com.sun.xml.internal.ws.request.timeout=100000
javax.xml.ws.soap.http.soapaction.use=null
com.sun.xml.internal.ws.client.ContentNegotiation=none
javax.xml.ws.soap.http.soapaction.uri=null

I've tried increasing the timeout but it still doesn't connect.

Has anyone else had a similar problem?


回答1:


As you mentioned the problem is of proxy, it has been answered in below links.

How to use an HTTP proxy in java

Proxy settings in a java program

If you are using proxy with authentication then you have set authenticator along with the proxy. This is answered here.

Authenticated HTTP proxy with Java

EDIT:

As correctly mentioned by William Burnham, you have set to set the properties before calling them. Morever, I recommend you to clear the property soon after getting response using System.clearProperty(key) as the property is set for complete instance of jvm till it is restarted and hence can cause problems for other outgoing connections.




回答2:


The problem was I was behind a proxy. I did different tests and found that using a web browser (or SoapUI) I was able to access the resource but from the command line it wasn't working.

After much searching, it was a simple fix: either passing the property as a jvm argument or manually setting it in the code with System.setProperty("java.net.useSystemProxies", "true"). The JVM wasn't using the proxy on its own.

EDIT

As I used wsimport I have a jax-ws client. It's important that proxy settings be configured prior to instantiantion.

ANOTHER EDIT

If by chance you're having problems and you're using an application server to make the soap request through the proxy, you may have to specify java.net.useSystemProxies=true (or similar) in the server's configuration--for example catalina.properties if using tomcat.



来源:https://stackoverflow.com/questions/50580220/soap-connection-timed-out-in-java-client-but-not-in-soapui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!