我在JAVA类中调用.net webservice,它将从文本文件中读取字符串,UTF8对该字符串进行编码并将该字符串返回给JAVA。有时正确的输出即将到来。但有时这会产生非法的参数异常,尽管文本文件中的文本格式正确。 以下是我得到的例外情况:
**SEVERE: Servlet.service() for servlet BaseController threw exception
java.lang.IllegalArgumentException: The char '0x0' after 'return code: 502
<HEAD><TITLE>Parent proxy is not responding</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>Parent proxy is not responding</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: Parent proxy is not responding</B></FONT>
<HR>
<!-- default "Parent proxy is not responding" response (502) -->
</BODY>
' is not a valid XML character.
at org.apache.axis.components.encoding.AbstractXMLEncoder.encode(AbstractXMLEncoder.java:110)
at org.apache.axis.utils.XMLUtils.xmlEncodeString(XMLUtils.java:131)
at org.apache.axis.utils.DOM2Writer.normalize(DOM2Writer.java:344)
at org.apache.axis.utils.DOM2Writer.print(DOM2Writer.java:246)
at org.apache.axis.utils.DOM2Writer.print(DOM2Writer.java:208)
at org.apache.axis.utils.DOM2Writer.serializeAsXML(DOM2Writer.java:77)
at org.apache.axis.utils.DOM2Writer.serializeAsXML(DOM2Writer.java:60)
at org.apache.axis.utils.DOM2Writer.nodeToString(DOM2Writer.java:49)
at org.apache.axis.utils.XMLUtils.privateElementToString(XMLUtils.java:433)
at org.apache.axis.utils.XMLUtils.ElementToString(XMLUtils.java:442)
at org.apache.axis.utils.XMLUtils.getInnerXMLString(XMLUtils.java:542)
at org.apache.axis.AxisFault.dumpToString(AxisFault.java:388)
at org.apache.axis.AxisFault.printStackTrace(AxisFault.java:789)
at java.lang.Throwable.printStackTrace(Throwable.java:451)
at com.hcl.webservice.BaseController.doPost(BaseController.java:155)
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.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:857)
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:680)
**
请帮助解决这个问题。 提前致谢
答案 0 :(得分:0)
消息显示完整后续字符串后的空字符(0x0):
return code: 502
<HEAD><TITLE>Parent proxy is not responding</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>Parent proxy is not responding</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: Parent proxy is not responding</B></FONT>
<HR>
<!-- default "Parent proxy is not responding" response (502) -->
</BODY>
不是有效的XML字符。换句话说,您遇到涉及父代理的网络问题,并且HTTP响应的正文包含HTML格式的问题的人类可读描述。您的服务客户端正在尝试将此文本解析为XML,从而解析您的错误。