未实现未连接的套接字

时间:2012-03-29 12:06:53

标签: java web-services ssl axis

我必须通过双向身份验证访问webservice。以下是我的方法。

创建了MyCustomSSLSocketFactory类。

  1. 已加载的TrustManagers
  2. 加载的密钥库管理器
  3. 创建SSL上下文和SSL套接字工厂,如下所示。
  4. 我在调用webservice方法之前调用了这个类方法。

    然后我做了如下: -

    AxisProperties.setProperty("axis.socketSecureFactory",
                                "com.elipva.zephyr.twofa.util.MyCustomSSLSocketFactory");
    
    Security.setProperty("ssl.SocketFactory.provider",
                        "com.elipva.zephyr.twofa.util.MyCustomSSLSocketFactory");
    
    
    SSLContext context = SSLContext.getInstance(protocolVersion);
    context.init(keyManagers, trustManagers, null);
    SSLSocketFactory socketFactory = context.getSocketFactory();
    
    URL url = new URL(urlString);
    URLConnection connection = url.openConnection();
      if (connection instanceof HttpsURLConnection) {
        ((HttpsURLConnection) connection)
                    .setSSLSocketFactory(sslSocketFactory);
    
                connection.connect();
            }   
    

    当我访问网络服务时,它会给我以下错误。

    org.apache.axis2.AxisFault: Unconnected sockets not implemented
        at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
        at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:203)
        at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
        at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
        at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
        at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    

    如果我错过了什么,请告诉我。

2 个答案:

答案 0 :(得分:1)

问题得到解决,只需在cacerts文件中导入证书。

答案 1 :(得分:0)

我认为这可能是这个Java错误 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6771432

请注意,这应该在java 1.6.0_u14

中修复