使用cxf 3.1.8的服务器中文件意外结束

时间:2018-11-15 09:47:46

标签: java web-services web cxf

我有一个服务,可以通过代理在其他服务器中调用另一个服务。 我想使用HTTPS协议,但出现此错误:

 Unexpected end of file from server

这是我的代码:

org.apache.cxf.endpoint.Client proxy2 = ClientProxy.getClient(client);
              HTTPConduit conduit = (HTTPConduit) proxy2.getConduit();
              conduit.getClient().setProxyServerType (ProxyServerType.SOCKS);
              TLSClientParameters tcp = new TLSClientParameters();
              tcp.setDisableCNCheck(false);
              tcp.setSecureSocketProtocol("SSL");
              TrustManager[] trustManager=new TrustManager[] { new DummyTrustManager() };
              tcp.setTrustManagers(trustManager);
              conduit.setTlsClientParameters(tcp);


              HTTPClientPolicy policy = new HTTPClientPolicy();
              policy.setConnectionTimeout(timeout);
              policy.setReceiveTimeout(timeout);
              conduit.setClient(policy);
              String port = System.getProperty("ProxyPort");

              System.setProperty("https.proxyHost", System.getProperty("ProxyServer"));
              System.setProperty("https.proxyPort", port);

              conduit.getClient().setProxyServer(System.getProperty("ProxyServer"));

              if(StringUtils.isNumeric(port)) {
                  conduit.getClient().setProxyServerPort(Integer.valueOf(port));
              }
              conduit.getProxyAuthorization().setUserName(System.getProperty("ProxyUser"));
              conduit.getProxyAuthorization().setPassword(System.getProperty("ProxyPwd"));
response = client.callService(request);

这是日志输出:

org.apache.cxf.binding.soap.SoapFault:将SAAJ模型写入流时出现问题:服务器中的文件意外结束     在org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor $ SAAJOutEndingInterceptor.handleMessage(SAAJOutInterceptor.java:224)〜[cxf-rt-bindings-soap-3.1.8.jar:3.1.8]     在org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor $ SAAJOutEndingInterceptor.handleMessage(SAAJOutInterceptor.java:174)〜[cxf-rt-bindings-soap-3.1.8.jar:3.1.8]     在org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)[cxf-rt-frontend-simple-3.1.8.jar:3.1.8]     在org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)[cxf-rt-frontend-jaxws-3.1.8.jar:3.1.8]     在com.sun.proxy。$ Proxy3394.unregisterAdvice_10(未知来源)[na:na]     在com.acp.vision.pcrd.ws.impl.UnregisterAdviceWebService.unregisterAdvice_10(UnregisterAdviceWebService.java:128)上[ws-core-impl-1.0.2..2.GA.jar:na]     在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:1.7.0]     在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)〜[na:1.7.0]     在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)〜[na:1.7.0]     在java.lang.reflect.Method.invoke(Method.java:613)〜[na:2.6(04-21-2013)]     在org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)上[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.jaxws.JAXWSMethodInvoker.performInvocation(JAXWSMethodInvoker.java:66)[cxf-rt-frontend-jaxws-3.1.8.jar:3.1.8]     在org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232)[cxf-rt-frontend-jaxws-3.1.8.jar:3.1.8]     在org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:85)[cxf-rt-frontend-jaxws-3.1.8.jar:3.1.8]     在org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:74)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.interceptor.ServiceInvokerInterceptor $ 1.run(ServiceInvokerInterceptor.java:59)[cxf-core-3.1.8.jar:3.1.8]     在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:482)[na:1.7.0]     在java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:345)[na:1.7.0]     在java.util.concurrent.FutureTask.run(FutureTask.java:177)[na:1.7.0]     在org.apache.cxf.interceptor.ServiceInvokerInterceptor $ 2.run(ServiceInvokerInterceptor.java:126)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)[cxf-core-3.1.8.jar:3.1.8]     在org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:252)[cxf-rt-transports-http-3.1.8.jar:3.1.8]     在org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)[cxf-rt-transports-http-3.1.8.jar:3.1.8]     在org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)[cxf-rt-transports-http-3.1.8.jar:3.1.8]     在org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)[cxf-rt-transports-http-3.1.8.jar:3.1.8]     在org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)[cxf-rt-transports-http-3.1.8.jar:3.1.8]     在org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:299)[cxf-rt-transports-http-3.1.8.jar:3.1.8]     在org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:218)[cxf-rt-transports-http-3.1.8.jar:3.1.8]     在javax.servlet.http.HttpServlet.service(HttpServlet.java:595)[javax.j2ee.servlet.jar:na]     在org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:274)[cxf-rt-transports-http-3.1.8.jar:3.1.8]     在com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1232)[com.ibm.ws.webcontainer.jar:na]     在com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:781)[com.ibm.ws.webcontainer.jar:na]     在com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:480)[com.ibm.ws.webcontainer.jar:na]     在com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)[com.ibm.ws.webcontainer.jar:na]     在com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1114)[com.ibm.ws.webcontainer.jar:na]     在com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)[com.ibm.ws.webcontainer.jar:na]     在com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:940)处[com.ibm.ws.webcontainer.jar:na]     在com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)[com.ibm.ws.webcontainer.jar:na]     在com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)[com.ibm.ws.webcontainer.jar:na]     com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)[com.ibm.ws.runtime.jar:na]     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)[com.ibm.ws.runtime.jar:na]     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)[com.ibm.ws.runtime.jar:na]     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287)[com.ibm.ws.runtime.jar:na]     在com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1049)上[com.ibm.ws.runtime.jar:na]     com.ibm.ws.ssl.channel.impl.SSLConnectionLink $ MyReadCompletedCallback.complete(SSLConnectionLink.java:643)[com.ibm.ws.runtime.jar:na]     com.ibm.ws.ssl.channel.impl.SSLReadServiceContext $ SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818)[com.ibm.ws.runtime.jar:na]     在com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)上[com.ibm.ws.runtime.jar:na]     在com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)[com.ibm.ws.runtime.jar:na]     在com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)上[com.ibm.ws.runtime.jar:na]     在com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)[com.ibm.ws.runtime.jar:na]     在com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)上[com.ibm.ws.runtime.jar:na]     在com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)[com.ibm.ws.runtime.jar:na]     在com.ibm.io.async.ResultHandler $ 2.run(ResultHandler.java:905)[com.ibm.ws.runtime.jar:na]     在com.ibm.ws.util.ThreadPool $ Worker.run(ThreadPool.java:1881)[com.ibm.ws.runtime.jar:na] 引起原因:com.ctc.wstx.exc.WstxIOException:服务器中的文件意外结束

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并且得到了解决。检查以下情况-

  1. 检查端点中的“ /”字符
  2. 在您的请求中检查允许的Http方法

首先尝试在您的服务器日志中找到某些内容,这可能会有帮助