Java套接字已关闭-在发布SOAP请求时

Java套接字已关闭-在发布SOAP请求时,java,soap,Java,Soap,第一次在此网站上发布问题。我一直在从事一个项目,在这个项目中,我必须生成一个签名(头x509)SOAP请求,并将其提交到Web服务所在的https URL。到目前为止,我已经能够生成签名的SOAP请求,但是当我发布请求时,我得到了一个socket is closed异常。有人能帮我找出我的代码丢失了什么可能导致这个错误吗。提前谢谢你 下面是我如何发布请求的代码以及错误: SSLContext sslcontext = SSLContexts.custom()

第一次在此网站上发布问题。我一直在从事一个项目,在这个项目中,我必须生成一个签名(头x509)SOAP请求,并将其提交到Web服务所在的https URL。到目前为止,我已经能够生成签名的SOAP请求,但是当我发布请求时,我得到了一个socket is closed异常。有人能帮我找出我的代码丢失了什么可能导致这个错误吗。提前谢谢你

下面是我如何发布请求的代码以及错误:

            SSLContext sslcontext = SSLContexts.custom()
                    .loadTrustMaterial(new File("my keystore"), "mypassword".toCharArray(),
                            new TrustSelfSignedStrategy())
                    .build();

            SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
                    sslcontext,
                    new String[] { "TLSv1" },
                    null,
                    SSLConnectionSocketFactory.getDefaultHostnameVerifier());
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(300 * 1000)
                    .setConnectTimeout(300 * 1000)
                    .setConnectionRequestTimeout(300 * 1000)
                    .build();
            HttpClient httpclient = HttpClients.custom() //CloseableHttpClient 
                    .setDefaultRequestConfig(requestConfig)
                    .setSSLSocketFactory(sslsf)
                    .build();

            HttpPost httpPost;
            httpPost = new HttpPost("https://my webservice");

            httpPost.setHeader("Content-type", "test/xml");

            File input = new File(esbXmlFile);

            InputStream inputStream = new FileInputStream(input);
            InputStreamEntity inputStreamEntity = new InputStreamEntity(inputStream);
            httpPost.setEntity(inputStreamEntity);


            String content = null;
            int statusCode = 1; //statusCode is response code form WS.
            try
             {
                 HttpResponse response = httpclient.execute(httpPost);
                 statusCode = response.getStatusLine().getStatusCode();
                 System.out.println("statusCode : " + statusCode);
                 HttpEntity entity = response.getEntity();
                 content = EntityUtils.toString(entity);

             }
            catch (SocketException e) {
                e.getStackTrace();
            }
            catch (IOException e) {
                 e.getStackTrace();
             }

 I get this error: 
            DEBUG (main) [org.apache.http.conn.ssl.SSLConnectionSocketFactory] - Starting handshake
        2016-11-28 16:24:04,019 DEBUG (main) [org.apache.http.impl.conn.DefaultManagedHttpClientConnection] - http-outgoing-1: Shutdown connection
        2016-11-28 16:24:04,019 DEBUG (main) [org.apache.http.impl.execchain.MainClientExec] - Socket is closed
        java.net.SocketException: Socket is closed
                at java.net.Socket.setSoLinger(Socket.java:986)
                at org.apache.http.impl.BHttpConnectionBase.shutdown(BHttpConnectionBase.java:305)
                at org.apache.http.impl.conn.DefaultManagedHttpClientConnection.shutdown(DefaultManagedHttpClientConnection.java:97)
                at org.apache.http.impl.conn.LoggingManagedHttpClientConnection.shutdown(LoggingManagedHttpClientConnection.java:89)
                at org.apache.http.impl.conn.CPoolEntry.shutdownConnection(CPoolEntry.java:74)
                at org.apache.http.impl.conn.CPoolProxy.shutdown(CPoolProxy.java:96)
                at org.apache.http.impl.execchain.ConnectionHolder.abortConnection(ConnectionHolder.java:127)
                at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:352)
                at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
                at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
                at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
                at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
                at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
                at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
                at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
也许你必须设置: setHeader(“内容类型”、“测试/xml”); 进入 setHeader(“内容类型”、“文本/xml”); 不同之处在于将test/xml转换为text/xml

可能您必须设置: setHeader(“内容类型”、“测试/xml”); 进入 setHeader(“内容类型”、“文本/xml”); 区别在于将test/xml转换为text/xml