https上的java ws客户端 - sslexception unexpected_message

时间:2014-11-13 21:52:22

标签: java web-services wcf https

我有一个使用wcf web服务的javax-ws客户端。

我在java 6中遇到了这个错误:

Exception in thread "main" javax.xml.ws.WebServiceException: java.net.SocketException: Connection reset
        at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
        at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
        at javax.xml.ws.Service.<init>(Unknown Source)
        at org.cnq.inforoute.services.client.SvcInforoute.<init>(SvcInforoute.java:46)
        at org.cnq.inforoute.services.test.Test.main(Test.java:60)
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(Unknown Source)
        at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
        at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
        at java.net.URL.openStream(Unknown Source)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(Unknown Source)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseImport(Unknown Source)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseImport(Unknown Source)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(Unknown Source)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
        ... 7 more

我一直在寻找解决方案,但没有任何效果。

使用ssl调试选项从命令行运行此客户端:

trigger seeding of SecureRandom
done seeding SecureRandom
Allow unsafe renegotiation: true
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
%% No cached client session
*** ClientHello, TLSv1
RandomCookie:  GMT: 1415914471 bytes = { 240, 207, 176, 165, 0, 90, 43, 90, 72, 190, 73, 63, 173, 75, 56, 89, 146, 189, 141, 161, 26, 115, 166, 191, 80, 157, 33, 16 }
Session ID:  {}
Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_E
_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5,
WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
Compression Methods:  { 0 }
***
main, WRITE: TLSv1 Handshake, length = 75
main, handling exception: java.net.SocketException: Connection reset
main, SEND TLSv1 ALERT:  fatal, description = unexpected_message
main, WRITE: TLSv1 Alert, length = 2
main, Exception sending alert: java.net.SocketException: Connection reset by peer: socket write error
main, called closeSocket()
Exception in thread "main" javax.xml.ws.WebServiceException: java.net.SocketException: Connection reset

我需要帮助! 感谢

1 个答案:

答案 0 :(得分:0)

尝试将端口与端点地址绑定。以下是一个例子:

final BindingProvider getProductsBp = (BindingProvider) GetProductsPort;
getProductsBp .getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,endpointAddress);

GetProductsPort对象是端口,endpointAddress是服务所在的地址。