First we need to create an instance of org.apache.commons.httpclient.protocol.Protocol.
Protocol myProtocolHandler = new Protocol("https", new MySSLSocketFactory(), 443);
MySSLSocketFactory should implement org.apache.commons.httpclient.protocol.ProtocolSocketFactory interface, which provides a method to get a new socket from a host name and port.
Then this needs to be passed to AxisEngine, through the message context.
or via the Options in service client
That's it. When you try to send a message using HTTPS, with the above configured message context, Axis2 will use the provided socket factory implementation.
You can provide a virtual protocol name to be used with your new socket factory as well. In order to do this, you just have to register your new protocol with HTTPClient. Nothing else is required to be passed in to Axis engine.
Protocol.registerProtocol("myhttps", new Protocol("https", new MySSLSocketFactory(), 9443));
This will enable you to use URLs like myhttps://www.myendpoint.com with SSL support. This won't change anything if you use HTTPS. If you want to change the behaviour of HTTPS for the whole system, then use https instead of myhttps.
Protocol.registerProtocol("https", new Protocol("https", new MySSLSocketFactory(), 9443));
JDK 1.4 or later
The SSL Guide in Apache Commons HTTP Client - How to Provide a Custom Socket Factory to be used in SSL Communication only with HTTPClient