UnknownHostException with SOAP and HTTPS
843790Dec 7 2008 — edited Dec 11 2008Running jre1.6.0_07 on Windows XP
I have a SOAP client that works perfectly with HTTP, but gives an UnknownHostException if I try HTTPS. The error is returned in the SOAP body as follows:
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Fault><faultcode>soapenv:Server.userException</faultcode><faultstring>java.net.UnknownHostException: x</faultstring><detail><ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">java.net.UnknownHostException: x
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:103)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:1870)
at org.apache.axis.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:90)
at nz.dataview.websyncclient.WebSYNCSOAPService.sendRequest(WebSYNCSOAPService.java:924)
at nz.dataview.websyncclient.WebSYNCSOAPService.doGetUploadStatus(WebSYNCSOAPService.java:738)
at nz.dataview.websyncclient.Client.run(Client.java:195)
at nz.dataview.websyncclient.Client.main(Client.java:1906)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
at java.lang.Thread.run(Unknown Source)
</ns1:stackTrace><ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">tims-laptop</ns2:hostname></detail></soapenv:Fault></soapenv:Body>
The message itself is encrypted (yes, the customer wants it encrypted twice!), base 64 encoded and then embedded in a wrapper SOAP request:
encoded = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
"<soapenv:Body>" +
"<base64binary>" + encoded + "</base64binary>" +
"</soapenv:Body>" + "</soapenv:Envelope>";
SOAPMessage smsg = MessageFactory.newInstance().createMessage(new MimeHeaders(), new byteArrayInputStream(encoded.getBytes()));
The SOAP request is sent using:
SOAPConnectionImpl conn = (SOAPConnectionImpl) SOAPConnectionFactoryImpl.newInstance().createConnection();
conn.setTimeout(new Integer(15000)); //15 seconds
SOAPMessage response = conn.call(smsg, endpoint);
conn.close();
So far, I've tried adding the domain to my hosts file, installing the server'sSSL certificate with keytool, and adding the lines
System.setProperty("javax.net.ssl.trustStore", "C:\\Program Files\\Java\\jre1.6.0_07\\bin\\client.keystore");
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
at the start, but it just gives the same error. I tried various port numbers, and changed the URL to https://www.facebook.com/login.php just to see if it was the server, but I still get the same error. No idea what this 'x' in 'UnknownHostException: x' is meant to be either!
Anyone have any ideas on how I can investigate this further?