我有一个类,它生成XML并发送这些XML,然后重定向到servlet。以下是代码段。出于安全原因,更改了类名。
public static void connectToApp(MyClass responseVO) {
AppHttpClient client = new AppHttpClient ();
ArrayList classRefList = new ArrayList();
ClientResponse clientResponse = null;
classRefList.add(Myclass.class);
Client httpClient = client.getDefaultHttpClient(classRefList);
WebResource webresource = null;
StringBuilder strUrl = new StringBuilder(getBaseUrl()).append("?username=").append("user1").append("&password=").append("user1pwd1").append("&appCode=").append("app1").append("&applicationXML=").append(createXML(responseVO)).append("&invokedBy=").append(responseVO.getAppName());
try {
webresource = httpClient.resource(uriEncode(strUrl.toString()));
clientResponse = webresource.header(APPConstants.WAKEUP, Boolean.TRUE.toString()).type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept((MediaType.MULTIPART_FORM_DATA)).get(ClientResponse.class);
} catch (Exception e) {
e.printStackTrace();
}
启用-Djavax.net.debug = all,我在控制台中收到以下消息。您也可以看到异常。
WebContainer-2, setSoTimeout(10000) called
%% No cached client session
*** ClientHello, TLSv1
RandomCookie: GMT: 1421516152 bytes = { 167, 34, 244, 184, 227, 79, 216, 52, 209, 35, 132, 130, 178, 7, 17, 15, 188, 138, 126, 228, 137, 164, 186, 49, 226, 95, 203, 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_EDE_CBC_SHA, SSL_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, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA]
Compression Methods: { 0 }
***
[write] MD5 and SHA1 hashes: len = 73
0000: 01 00 00 45 03 01 55 BB 9D 78 A7 22 F4 B8 E3 4F ...E..U..x."...O
0010: D8 34 D1 23 84 82 B2 07 11 0F BC 8A 7E E4 89 A4 .4.#............
0020: BA 31 E2 5F CB 10 00 00 1E 00 04 00 05 00 2F 00 .1._........../.
0030: 33 00 32 00 0A 00 16 00 13 00 09 00 15 00 12 00 3.2.............
0040: 03 00 08 00 14 00 11 01 00 .........
WebContainer-2, WRITE: TLSv1 Handshake, length = 73
[write] MD5 and SHA1 hashes: len = 98
0000: 01 03 01 00 39 00 00 00 20 00 00 04 01 00 80 00 ....9... .......
0010: 00 05 00 00 2F 00 00 33 00 00 32 00 00 0A 07 00 ..../..3..2.....
0020: C0 00 00 16 00 00 13 00 00 09 06 00 40 00 00 15 ............@...
0030: 00 00 12 00 00 03 02 00 80 00 00 08 00 00 14 00 ................
0040: 00 11 55 BB 9D 78 A7 22 F4 B8 E3 4F D8 34 D1 23 ..U..x."...O.4.#
0050: 84 82 B2 07 11 0F BC 8A 7E E4 89 A4 BA 31 E2 5F .............1._
0060: CB 10 ..
WebContainer-2, WRITE: SSLv2 client hello message, length = 98
[Raw write]: length = 100
0000: 80 62 01 03 01 00 39 00 00 00 20 00 00 04 01 00 .b....9... .....
0010: 80 00 00 05 00 00 2F 00 00 33 00 00 32 00 00 0A ....../..3..2...
0020: 07 00 C0 00 00 16 00 00 13 00 00 09 06 00 40 00 ..............@.
0030: 00 15 00 00 12 00 00 03 02 00 80 00 00 08 00 00 ................
0040: 14 00 00 11 55 BB 9D 78 A7 22 F4 B8 E3 4F D8 34 ....U..x."...O.4
0050: D1 23 84 82 B2 07 11 0F BC 8A 7E E4 89 A4 BA 31 .#.............1
0060: E2 5F CB 10 ._..
WebContainer-2, received EOFException: error
WebContainer-2, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
WebContainer-2, SEND TLSv1 ALERT: fatal, description = handshake_failure
WebContainer-2, WRITE: TLSv1 Alert, length = 2
[Raw write]: length = 7
0000: 15 03 01 00 02 02 28 ......(
WebContainer-2, called closeSocket()
WebContainer-2, called close()
WebContainer-2, called closeInternal(true)
WebContainer-2, called close()
WebContainer-2, called closeInternal(true)
WebContainer-2, called close()
WebContainer-2, called closeInternal(true)
21:38:25,203 ERROR WebContainer-2 utils.ComUtil:205 - Error while connecting appstore javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
44883 [WebContainer-2] ERROR java.com.common.utils.ComUtil - Error while connecting appstore javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at com.sun.jersey.client.apache.DefaultApacheHttpMethodExecutor.executeMethod(DefaultApacheHttpMethodExecutor.java:213)
at com.sun.jersey.client.apache.ApacheHttpClientHandler.handle(ApacheHttpClientHandler.java:175)
at com.sun.jersey.api.client.Client.handle(Client.java:648)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:507)
at java.com.common.utils.ComUtil.connectTApp(ComUtil.java:203)
at java.com.common.controller.AppCodeListController.setValuesToResponse(AppCodeListController.java:174)
at java.com.common.controller.AppCodeListController.submitAppCodeList(AppCodeListController.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.javaalina.core.ApplijavaionFilterChain.internalDoFilter(ApplijavaionFilterChain.java:290)
at org.apache.javaalina.core.ApplijavaionFilterChain.doFilter(ApplijavaionFilterChain.java:206)
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:808)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1120)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:828)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.flushRequestOutputStream(MultiThreadedHttpConnectionManager.java:1565)
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2116)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at com.sun.jersey.client.apache.DefaultApacheHttpMethodExecutor.executeMethod(DefaultApacheHttpMethodExecutor.java:210)
... 52 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:333)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:789)
... 65 more
Finalizer, called close()
Finalizer, called closeInternal(true)
请帮我解决这个问题。