Soap Connection在Java客户端中超时,但在SOAPUI中超时 [英] Soap Connection timed out in Java client but not in SOAPUI
问题描述
我用wsimport
和给定的wsdl创建了一个soap客户端.我还使用了SoapUI来测试服务.使用SoapUI没问题,但是使用Java客户端时,我得到
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
requestContext
中的默认值如下
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?
推荐答案
问题是我在代理后面.我进行了不同的测试,发现使用Web浏览器(或SoapUI)可以访问该资源,但无法从命令行访问该资源.
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.
经过大量搜索之后,这是一个简单的解决方案:将属性作为jvm参数传递,或者使用System.setProperty("java.net.useSystemProxies", "true")
在代码中手动设置. JVM并不是单独使用代理.
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.
编辑
当我使用wsimport
时,我有一个jax-ws客户端.在实例化之前配置代理设置很重要.
As I used wsimport
I have a jax-ws client. It's important that proxy settings be configured prior to instantiantion.
另一个编辑
如果偶然遇到问题,并且您正在使用应用程序服务器通过代理发出Soap请求,则可能必须在服务器的配置中指定java.net.useSystemProxies=true
(或类似名称)-例如catalina.properties(如果使用的是tomcat).
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.
这篇关于Soap Connection在Java客户端中超时,但在SOAPUI中超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!