0

我正在尝试通过我的 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]

但是看着这个很难找到错误在哪里。无论如何我可以解决这个错误。

4

1 回答 1

0

As exception suggests, some String (character data value) in object you trying to write out contains null character (Unicode zero). Beyond finding and fixing corrupt String value(s), you can also work around the problem by making Woodstox change such invalid character values. See How to alleviate the infamous "Xml Invalid Character" problem with Woodstox .

于 2013-05-05T17:56:40.060 回答