Axis 2 webservice SSL通信
我从这段代码得到了Soap Response
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc.createConnection(); SOAPMessage soapMessageResponse = connection.call(soapRequest, new URL(serviceLocation));
如何使其基于SSL?
我知道如何从SSLContext
创建SSLSocketFactory
给我指定的密钥库 。
如何告诉SOAPConnection
类有关SSLSocketFactory
或SSLContext
? 这样我的沟通就可以得到保障。
我不想在系统属性或xml文件中设置密钥库。 我正在使用Websphere 7。
编辑:
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
登录管理控制台并通过SSL证书和密钥管理> SSL配置> NodeDefaultSSLSettings>密钥库和证书> NodeDefaultTrustStore>签署者证书添加证书
通常,除了提供以https://开头的端点URL之外,您不需要执行任何操作。
Axis2使用http-commons,而后者将使用JSSE来处理安全问题。 因此,只要您正确配置了JSSE,它就应该开箱即用,除了在URL中传递https之外没有任何变化。
伊姆兰,你试过这个小费吗? “您必须从您尝试连接的远程主机检索签名者证书并将其添加到WAS服务器信任库”
http://turanunes.wordpress.com/2011/05/04/cwpki0022e-ssl-handshake-failure/
这行代码在SSL的情况下不起作用。
SOAPMessage soapMessageResponse = connection.call(soapRequest, new URL(serviceLocation));
为了通过来自axis2 webservice的SSL获得响应,您需要打开像[here][1]
这样的流。