xfire webservice异常 java.lang.IllegalStateException: Can't overwrite cause

 ERROR [PostInvocationHandler:40] java.lang.IllegalStateException: Can't overwrite cause
ERROR [DefaultFaultHandler:35] Fault occurred!
java.lang.IllegalStateException: Can't overwrite cause
 at java.lang.Throwable.initCause(Throwable.java:320)
 at com.ctc.wstx.compat.Jdk14Impl.setInitCause(Jdk14Impl.java:70)
 at com.ctc.wstx.exc.WstxException.(WstxException.java:46)
 at com.ctc.wstx.exc.WstxIOException.(WstxIOException.java:16)
 at com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:505)
 at org.codehaus.xfire.aegis.stax.ElementWriter.writeValue(ElementWriter.java:138)
 at org.codehaus.xfire.aegis.type.basic.StringType.writeObject(StringType.java:26)
 at org.codehaus.xfire.aegis.type.basic.BeanType.writeObject(BeanType.java:392)
 at org.codehaus.xfire.aegis.type.basic.ArrayType.writeValue(ArrayType.java:298)
 at org.codehaus.xfire.aegis.type.collection.CollectionType.writeObject(CollectionType.java:103)
 at org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter(AegisBindingProvider.java:229)
 at org.codehaus.xfire.service.binding.AbstractBinding.writeParameter(AbstractBinding.java:273)
 at org.codehaus.xfire.service.binding.WrappedBinding.writeMessage(WrappedBinding.java:90)
 at org.codehaus.xfire.soap.SoapSerializer.writeMessage(SoapSerializer.java:80)
 at org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(HttpChannel.java:56)
 at org.codehaus.xfire.transport.http.XFireServletChannel.sendViaServlet(XFireServletChannel.java:87)
 at org.codehaus.xfire.transport.http.XFireServletChannel.send(XFireServletChannel.java:44)
 at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
 at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
 at org.codehaus.xfire.service.binding.PostInvocationHandler.invoke(PostInvocationHandler.java:36)
 at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
 at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
 at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
 at org.codehaus.xfire.transport.http.XFireServletController.invoke(XFireServletController.java:304)
 at org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:129)
 at org.codehaus.xfire.transport.http.XFireServlet.doPost(XFireServlet.java:116)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at com.ulane.sentry.filter.LoginFilter.authenticate(LoginFilter.java:110)
 at com.ulane.sentry.filter.LoginFilter.doFilter(LoginFilter.java:98)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
 at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
 at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
 at java.lang.Thread.run(Thread.java:619)

=========================================================================================

异常原因:webservice传输的数据中,有特殊字符或者乱码!

解决方案:将特殊字符或者乱码过滤掉

 public static final String chopWhitespace(String str) {
  if(null==str || "".equals(str))return "";

  StringBuilder sb = new StringBuilder("");
  for (int i = 0; i < str.length(); i++) {
   char ch = str.charAt(i);
   int ci = ch;
   //System.out.println(ch+" "+ci);
   if (9 == ci || 10 == ci || 13 == ci || 32 <= ci && !Character.isISOControl(ci)) {
    sb.append(ch);
   }
  }
  return sb.toString();
 }

 

你可能感兴趣的:(webservice,java)