我试图通过我的WS将服务器端的一些数据进程传递给客户端。
但是我收到了这个错误:
SEVERE: caught throwable
javax.xml.ws.WebServiceException: com.ctc.wstx.exc.WstxIOException: Invalid null character in text to output
at com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:112)
at com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:278)
at com.sun.xml.ws.transport.http.HttpAdapter.encodePacket(HttpAdapter.java:380)
at com.sun.xml.ws.transport.http.HttpAdapter.access$100(HttpAdapter.java:92)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:525)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:285)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:143)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:155)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:189)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:76)
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 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.valves.AccessLogValve.invoke(AccessLogValve.java:555)
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.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid null character in text to output
at com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:520)
at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:135)
at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:138)
at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:138)
at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:138)
at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:138)
at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:138)
at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:138)
at com.sun.xml.ws.message.saaj.SAAJMessage.writeTo(SAAJMessage.java:365)
at com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:109)
... 24 more
Caused by: java.io.IOException: Invalid null character in text to output
at com.ctc.wstx.sw.XmlWriter.throwInvalidChar(XmlWriter.java:538)
at com.ctc.wstx.sw.BufferingXmlWriter.writeCharacters(BufferingXmlWriter.java:453)
at com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:518)
将响应发送回客户端时抛出此异常。
在客户端这是响应:
ParseError at [row,col]:[1,11347]
但是看着这很难找到错误在哪里。无论如何我可以解决这个错误。
如异常所示,您尝试写出的对象中的某些字符串(字符数据值)包含空字符(Unicode零)。除了查找和修复损坏的字符串值之外,您还可以通过使Woodstox更改此类无效字符值来解决此问题。见How to alleviate the infamous "Xml Invalid Character" problem with Woodstox 。