Вот два способа справиться с WS по SSL http://ws.apache.org/xmlrpc/ssl.html.
Правильный способ - настроить и использовать хранилище ключей для решений SE и EE.
Следующее быстрое решение также работает для меня:
package client;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.xml.namespace.QName;
import ws.MyService1;
import ws.MyService1ServiceLocator;
public class Client {
public static void main(String[] args) throws Exception {
test();
}
public static void test() throws Exception {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
// Trust always
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
// Trust always
}
} };
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("SSL");
// Create empty HostnameVerifier
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
};
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(hv);
// use secured service
QName qname = new QName("http://ws", "MyService1Service");
String url = "https://127.0.0.1:7002/MyService/wsdl/MyService1.wsdl";
MyService1 service = new MyService1ServiceLocator(url, qname).getMyService1();
System.out.println(service.getMessage());
}
}