HTTP transport error: java.net.ConnectException: Connection timed out: connect in Soap ws client
HTTP transport error: java.net.ConnectException: Connection timed out: connect in Soap ws client
在我开发的 JAR 客户端中,当尝试使用 jax-ws 调用 soap ws 时出现连接超时异常,我想知道导致此异常的原因。
我正在使用远程 wsdl,并且 https 的服务器证书在 VM 参数中必须是 运行。
-Djavax.net.debug=all
-Djavax.net.ssl.trustStore=link to my certifacte
我如何 运行 使用此参数?
通过添加它们 eclipse.ini 文件?
感谢您的帮助。
1. Select 您从 Project Explorer 窗格中投影,通常在左侧
2。在 运行 菜单中,根据您是要 运行 还是调试它,单击 运行 或 Debug
3。在左窗格中,select "Java Application and right click and click New"
4。由于您已经 select 编辑了您的项目并且它包含一个 "Main" class,它将默认 Run/Debug 配置 "Name" 到 class名称。如果您有多个 Main,您可能需要单击“搜索”按钮或手动输入包路径和 class 名称
5。在 "VM arguments" 下输入您的参数,如图所示
6。单击应用,或者单击应用和 运行 如果您想 运行 它立即
一些注意事项,您可能需要密钥库的完整路径,例如:
-Djavax.net.ssl.trustStore=C:\ADirectory\AnotherDirectory\FinalDirectoryThatContainsYourKeystore\TrustStore.jks
-Djavax.net.debug=all
- 将开启大量调试,如果您不习惯阅读它,可能会造成混淆。如果连接有效,请删除该行。如果连接不起作用 - 那就是所有调试都有用的时候。
更新:为了进一步解决 HTTP 连接问题,当它的核心是 SOAP 请求时,暂时删除 -Djavax.net.debug=all
并添加以下内容:
-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true
-Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true
-Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true
-Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true
这将向您显示 HTTP headers、响应代码、请求和响应 body 内容。它还将显示您尝试连接的 URL。
添加额外的故障排除答案。测试 SSL 连接的好方法。资料来源:4ndrej awesome SSL Poke GitHUB example
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*
* JGlass: Code modified for SO to hard code the host and port
*
*/
public class SSLPoke {
public static void main(String[] args) {
//add the full FQDN to the host here
String host = "google.com";
//your port may be 443
int port = 8443;
try {
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(host, port);
InputStream in = sslsocket.getInputStream();
OutputStream out = sslsocket.getOutputStream();
// Write a test byte to get a reaction :)
out.write(1);
while (in.available() > 0) {
System.out.print(in.read());
}
System.out.println("Successfully connected");
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
如果一切正常,你会得到 "Successfully Connected"
在我开发的 JAR 客户端中,当尝试使用 jax-ws 调用 soap ws 时出现连接超时异常,我想知道导致此异常的原因。 我正在使用远程 wsdl,并且 https 的服务器证书在 VM 参数中必须是 运行。
-Djavax.net.debug=all
-Djavax.net.ssl.trustStore=link to my certifacte
我如何 运行 使用此参数? 通过添加它们 eclipse.ini 文件? 感谢您的帮助。
1. Select 您从 Project Explorer 窗格中投影,通常在左侧
2。在 运行 菜单中,根据您是要 运行 还是调试它,单击 运行 或 Debug
3。在左窗格中,select "Java Application and right click and click New"
4。由于您已经 select 编辑了您的项目并且它包含一个 "Main" class,它将默认 Run/Debug 配置 "Name" 到 class名称。如果您有多个 Main,您可能需要单击“搜索”按钮或手动输入包路径和 class 名称
5。在 "VM arguments" 下输入您的参数,如图所示
6。单击应用,或者单击应用和 运行 如果您想 运行 它立即
一些注意事项,您可能需要密钥库的完整路径,例如:
-Djavax.net.ssl.trustStore=C:\ADirectory\AnotherDirectory\FinalDirectoryThatContainsYourKeystore\TrustStore.jks
-Djavax.net.debug=all
- 将开启大量调试,如果您不习惯阅读它,可能会造成混淆。如果连接有效,请删除该行。如果连接不起作用 - 那就是所有调试都有用的时候。
更新:为了进一步解决 HTTP 连接问题,当它的核心是 SOAP 请求时,暂时删除 -Djavax.net.debug=all
并添加以下内容:
-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true
-Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true
-Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true
-Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true
这将向您显示 HTTP headers、响应代码、请求和响应 body 内容。它还将显示您尝试连接的 URL。
添加额外的故障排除答案。测试 SSL 连接的好方法。资料来源:4ndrej awesome SSL Poke GitHUB example
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*
* JGlass: Code modified for SO to hard code the host and port
*
*/
public class SSLPoke {
public static void main(String[] args) {
//add the full FQDN to the host here
String host = "google.com";
//your port may be 443
int port = 8443;
try {
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(host, port);
InputStream in = sslsocket.getInputStream();
OutputStream out = sslsocket.getOutputStream();
// Write a test byte to get a reaction :)
out.write(1);
while (in.available() > 0) {
System.out.print(in.read());
}
System.out.println("Successfully connected");
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
如果一切正常,你会得到 "Successfully Connected"