我对这个问题做了一些研究,但似乎所有其他答案都包括更改向您发送响应的方式。我正在调用第三方 Web 服务,该服务返回一个 xml 字符串。当我在本地 Win7 机器上执行此操作时效果很好。但是当我将其发送到我们的服务器 Win Server 2003 时,我收到此错误返回:
Error 500: Executing action [vinlookup] of controller [AutoVehicleController] caused exception: null
Servlet: grails
URI: /NonProfits/grails/autoVehicle/vinlookup.dispatch
Exception Message: An invalid XML character (Unicode: 0x5c) was found in the public identifier.
Caused by: An invalid XML character (Unicode: 0x5c) was found in the public identifier.
Class: AutoVehicleController
At Line: [172]
Code Snippet:
Stack Trace
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x5c) was found in the public identifier.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at VinPowerService.decodeVin(VinPowerService.groovy:40)
at VinPowerService$$FastClassByCGLIB$$6f8d198b.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at VinPowerService$$EnhancerByCGLIB$$f1db38bd.decodeVin(<generated>)
at VinPowerService$decodeVin.call(Unknown Source)
at AutoVehicleController$_closure7.doCall(AutoVehicleController.groovy:172)
at AutoVehicleController$_closure7.doCall(AutoVehicleController.groovy)
at java.lang.Thread.run(Thread.java:619)
最佳答案
消息非常明确:
An invalid XML character (Unicode: 0x5c) was found in the public identifier.
“公共(public)标识符”是出现在 DOCTYPE 声明中关键字 PUBLIC 之后的字符串。公共(public)标识符中可以出现哪些字符是有规则的,并且不允许出现反斜杠。
你有一个选择。说服生成此标识符的人改正他们的方式,或者编写某种脚本来修复收到的错误 XML。不太可能有人关心公共(public)标识符的值是什么,因此您可以删除反斜杠而不造成任何损害。
关于xml - Grails 错误 : invalid XML character (Unicode: 0x5c),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11688440/