Search code examples
javasoapjax-wswebservice-client

HTTP transport error: java.net.ConnectException: Connection timed out: connect in Soap ws client


In my JAR client that i developed, When trying to call a soap ws using jax-ws i got connection timeout exception, i want to know what can be the reasons that causes this exception. I am using a remote wsdl, and server certificate for https that must be run in VM arguments.

   -Djavax.net.debug=all
   -Djavax.net.ssl.trustStore=link to my certifacte

How can i run with this arguments? By adding them eclipse.ini file ? Thanks for your help.


Solution

  • 1. Select you project from the Project Explorer Pane, generally on the left Step 1

    2. From the Run menu, depending on whether you want to just run it or debug it click either Run or Debug Step 2

    3. In left pane, select "Java Application and right click and click New" enter image description here

    4. Since you've already selected your project and it contains a "Main" class, it will default the Run/Debug configuration "Name" to the class name. If you have multiple Main's, you may have to click the Search button or manually type in the package path and class name Step 4

    5. Enter your arguments under "VM arguments" as shown Step 5

    6. Click Apply, or Apply and the Run if you want to run it immediately

    Some notes, you'll likely need the full path to the keystore such as:
    -Djavax.net.ssl.trustStore=C:\ADirectory\AnotherDirectory\FinalDirectoryThatContainsYourKeystore\TrustStore.jks

    -Djavax.net.debug=all - is going to turn on a MASSIVE amount of debug which if you're not used to reading it, it can be confusing. If the connection works remove that line. If the connection doesn't work - thats when all that debug is useful.

    Update: to further troubleshoot HTTP connectivity problems, when at the heart of it thats what a SOAP request is, temporarily remove the -Djavax.net.debug=all and add the following instead:
    -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

    This will show you the HTTP headers, response code, request and response body contents. It will also show the URL you are trying to connect to.