xml - Grails 错误 : invalid XML character (Unicode: 0x5c)

标签 xml web-services grails groovy

我对这个问题做了一些研究,但似乎所有其他答案都包括更改向您发送响应的方式。我正在调用第三方 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/

相关文章:

grails - 如何使Grails子查询作为简单示例?

android - 是否可以在同一个 button.xml 存档中定义具有背景可绘制行为的多个按钮?

php - PHP XML-找出已知值的路径

c# - xml列表反序列化只取一个元素

java - 无法调用远程端点 alexa

grails - grails 用于处理上传文件的不同类

android - "Content has view with id attribute ' android.r.id.list ' that is not a ListView Class."在 fragment 中创建 ListView 时

c# - 从 ASP.NET Core Web 方法提供 SOAP

java - 在基本网络服务中获取异常

gwt - 在 grails 中集成现有的 gwt 应用程序