在网上找了好多CXF 调用 https的方法,没有写怎么集成Spring的。自己在此记录一下。
在AuthorizeQueryProxyImpl类的方法中
private com.test.services.ServerPortType port; //由Spring 进行 set 注入
private String keystoreFile; //jks 文件位置
private String keystorePasswd; //jks 的storepass
public String authorizeQuery(String username) {
//在调用 Https的服务前,先配置SSL连接
HTTPSslTool.configureSSLOnTheClient(port, getKeystoreFile(), getKeystorePasswd());
......
return port.authrQuery(reqQuery,rsp);
}
写一个建立SSL连接的方法:
public class HTTPSslTool {
public static void configureSSLOnTheClient(Object obj, String jksPath, String jksPwd) {
File file = new File(jksPath);
Client client = ClientProxy.getClient(obj);
HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
try {
TLSClientParameters tlsParams = new TLSClientParameters();
tlsParams.se