Axis 2 webservice SSL communication

匆匆过客 提交于 2020-01-03 06:33:54

问题


I am getting Soap Response from this code

SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
SOAPConnection connection = sfc.createConnection();
SOAPMessage soapMessageResponse = connection.call(soapRequest, new URL(serviceLocation));

How can I make it SSL based?

I know how to create SSLSocketFactory from SSLContext giving my specified keystore.

How can I tell SOAPConnection class about SSLSocketFactory or SSLContext? So that my communication can be secured.

I do not want to set keystore in system property or xml file. I am using Websphere 7.

EDIT:

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at com.ibm.ws.webservices.engine.soap.SOAPConnectionImpl.callJAXWSDispatch(SOAPConnectionImpl.java:416)
    ... 49 more
Caused by: javax.xml.soap.SOAPException: javax.xml.ws.WebServiceException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
    at com.ibm.ws.webservices.engine.xmlsoap.saaj13only.SOAPConnectionJAXWS.call(SOAPConnectionJAXWS.java:72)
    ... 54 more
Caused by: javax.xml.ws.WebServiceException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem

回答1:


Log in to Admin console and add the certificate via SSL certificate and key management > SSL configurations > NodeDefaultSSLSettings > Key stores and certificates > NodeDefaultTrustStore > Signer certificates




回答2:


Typically you dont need to do anything apart from giving your endpoint URL that starts with https://.

Axis2 uses http-commons which in turn will use JSSE takes care of the security. So as long as you have configured your JSSE correctly it should work out of the box with no changes except passing the https in URL.




回答3:


Imran, did you try this tip? "you have to retrieve the signer certificates from the remote host you are trying to connect and adding them to the WAS server trust store"

http://turanunes.wordpress.com/2011/05/04/cwpki0022e-ssl-handshake-failure/




回答4:


This line of code will not work in case of SSL.

SOAPMessage soapMessageResponse = connection.call(soapRequest, new URL(serviceLocation));

In order to get response through SSL from axis2 webservice you need to open streams like given [here][1].



来源:https://stackoverflow.com/questions/10897881/axis-2-webservice-ssl-communication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!