I'm trying to call a web service for which I send xml data with a POST AND I get a response back.
The production web service requires a certificate for which I was given. I have imported this certificate to my keystore and have used it in my client code but I keep getting timed out errors.
Do you know what can be causing this issue?
17:30:15,214 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) java.net.ConnectException: Operation timed out
17:30:15,214 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at java.net.PlainSocketImpl.socketConnect(Native Method)
17:30:15,215 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
17:30:15,215 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
17:30:15,215 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
17:30:15,216 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
17:30:15,216 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at java.net.Socket.connect(Socket.java:579)
17:30:15,216 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
17:30:15,216 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:407)
17:30:15,217 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
17:30:15,217 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at hot.com.mhd.erp.action.client.PushStatusClient.pushXML(PushStatusClient.java:478)
17:30:15,217 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at main.com.mhd.erp.sched.StatusPushJob.execute(StatusPushJob.java:73)
17:30:15,218 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
17:30:15,218 ERROR [stderr] (DefaultQuartzScheduler_Worker-6) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
The company has whitelisted the ip address and not running behind a firewall, can this connectivity issue be related to the certificates not being used properly? I have imported them to my keystore but do I need to do something else in my code or with JBoss (which is hosting the application)
I have also done this to set the keystore, password, type etc.
System.setProperty("https.protocols", "SSLv3");
System.setProperty("javax.net.ssl.trustStore", ERPGetProperty.erpGetProperty("pathToKeyStore"));
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.keyStore", ERPGetProperty.erpGetProperty("pathToKeyStore"));
System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
System.setProperty("javax.net.ssl.keyStoreType", "JKS");
URL url = new URL(address);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setConnectTimeout(10000);
SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
con.setSSLSocketFactory(sslSocketFactory);
con.setRequestMethod("POST");
con.setUseCaches(true);
con.setRequestProperty("Content-type", "text/xml");
con.setRequestProperty("Host", "pwspg.newcorp.com");
con.setRequestProperty("Content-Length", Integer.toString(xml.length()));
con.setRequestProperty("SOAPAction", address);
con.setDoOutput(true);
con.setDoInput(true);
userPass = username + ":" + password;
byte[] encodeBytes = Base64.encodeBase64(userPass.getBytes());
String encode = new String(encodeBytes);
con.setRequestProperty("Authorization", "Basic " + encode);
out = con.getOutputStream();
out.write(b);
UPDATE: I have been confirmed by the web service owners again that my IP address has been whitelisted. I used telnet to test the host and the connection times out. If I ping it, I do receive packets. What else can be causing the issue of not being able to connect to the web service?
I have been told that it doesn't have to do with the certificates but I can't seem to find what's the problem. Is this a problem on my end?