将Apache HttpClient 4.5配置为Axis2存根中的传输发送方,如何使用Axis2使用httpClient4配置SSL。

问题描述 投票:0回答:1
我正在将Apache Httpclient 3.1替换为4.5版本,我们的应用程序使用的是AXIS 2 SOAP Web服务存根,其下面使用的是HTTPClient 3.1 TransportSender。我需要迁移它以使用HttpClient 4.5版本。下面是需要迁移到HttpClient 4.5版本的完整代码:

import org.apache.commons.httpclient.protocol.Protocol; // 3.1 version import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; // 3.1 version final Options clientOptions = stub._getServiceClient().getOptions(); clientOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, new Protocol("https", new TLSSocketFactory(), 443)); public class TLSSocketFactory extends SSLSocketFactory implements SecureProtocolSocketFactory { private SSLSocketFactory internalSSLSocketFactory; public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException { SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); internalSSLSocketFactory = context.getSocketFactory(); } @Override public String[] getDefaultCipherSuites() { return internalSSLSocketFactory.getDefaultCipherSuites(); } @Override public String[] getSupportedCipherSuites() { return internalSSLSocketFactory.getSupportedCipherSuites(); } @Override public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException { return enableTLSOnSocket(internalSSLSocketFactory.createSocket(s, host, port, autoClose)); } @Override public Socket createSocket(String host, int port) throws IOException, UnknownHostException { return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port)); } @Override public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException { return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port, localHost, localPort)); } @Override public Socket createSocket(String s, int i, InetAddress inetAddress, int i1, HttpConnectionParams httpConnectionParams) throws IOException, UnknownHostException, ConnectTimeoutException { return enableTLSOnSocket(internalSSLSocketFactory.createSocket(s, i, inetAddress, i1)); } @Override public Socket createSocket(InetAddress host, int port) throws IOException { return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port)); } @Override public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { return enableTLSOnSocket(internalSSLSocketFactory.createSocket(address, port, localAddress, localPort)); } private Socket enableTLSOnSocket(Socket socket) { if(socket != null && (socket instanceof SSLSocket)) { ((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"}); } return socket; }

}

我遇到了这个StackOverflow帖子:How to configure SSL with Axis2 using httpClient4

但是在帖子中明确提到它仅与httpclient 4.4.1兼容。

Axis2 1.7.0除了不支持Apache HttpClient 4.x维护时间更长的Commons HttpClient3.x。启用对HttpClient 4.x,使用org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender代替org.apache.axis2.transport.http.CommonsHTTPTransportSender在axis2.xml中。请注意,该代码是为HttpClient编写的4.2.x,应该与4.3.x和4.4.x兼容,但与4.5.x不兼容。

我们使用的是HttpClient 4.5,它明确表示它与4.5.x不兼容

我真的很困惑,在迁移以上代码以使用HttpClient 4.5时需要帮助。

提前感谢。

我正在将Apache Httpclient 3.1替换为4.5版本,我们的应用程序使用的是AXIS 2 SOAP Web服务存根,其下面使用的是HTTPClient 3.1 TransportSender。我需要迁移...

java ssl axis2 apache-httpclient-4.x soap-client
1个回答
0
投票
您在哪里可以解决此问题?我看到类似的问题
© www.soinside.com 2019 - 2024. All rights reserved.