2012-07-27 5 views
2

이 문제에 대해 조금 연구했지만 응답에 대한 응답 방식이 변경되는 것 같습니다. xml 문자열을 반환하는 제 3 자 웹 서비스를 호출하고 있습니다. 내 로컬 Win7 시스템에서 할 때 잘됩니다. 나는 우리 서버, 승리 Server 2003으로 그것을 둘 때, 나는이 오류 수익을 얻을 :Grails 오류 : XML 문자 (유니 코드 : 0x5c)가 유효하지 않습니다.

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) 
+0

당신은 웹 서비스를 호출하는 방법을 말하지 않거나이 오류가 발생하는 코드를 보여 주거나 사용중인 Grails 및 관련 플러그인의 버전을 말하십시오. 유용 할 수 있습니까? –

답변

2

메시지는 꽤 명시 적입니다 ... 오류가 발생하고, 서버는 문자열을 반환하지만, 전에 공백을 추가하고 싶어하고, DOCTYPE 선언의 키워드 PUBLIC. 공개 식별자에는 어떤 문자가 나타날 수 있는지에 대한 규칙이 있으며 백 슬래시는 허용되지 않습니다.

선택의 여지가 있습니다. 이 식별자를 생성 한 사람들을 설득하여 자신의 방식을 수정하거나 영수증에 잘못된 XML을 복구하는 일종의 스크립트를 작성하십시오. 공개 식별자의 가치는 누구나 염려하지 않으므로 손상을 입히지 않고 백 슬래시를 삭제할 수 있습니다.

1

0x5c에는 "이스케이프 시퀀스"를 사용할 수있는 "구타"문자 \이다. 따라서 XML 콘텐츠의 경우 자체를 이스케이프 처리해야합니다. HTMLEncode (여기 메모리에서 그리기)와 같은 도우미 함수가 있어야합니다.이 함수는 모든 문자를 "이스케이프 된 버전"으로 변환합니다 (즉, &&이됩니다).

+0

''\''는 XML에서 이스케이프 처리에 사용되지 않습니다. 그것은 보통 구두점 문자입니다. 하지만 특정 구두점 문자 만 허용하는 이름 토큰 (예 : 태그 이름 또는 속성 이름)에서는 유효하지 않습니다. – ataylor

+0

사실, 나는 명확히하지 않았다. – Darek

+0

아마도 이것이 적용될 수 있습니까? [link] (http://stackoverflow.com/questions/5858684/getting-jdomexception-on-one-machine-but-the-same-xml-works-fine-in-another) – Darek

0

XML 형식이 양호한 경우 첫 번째 노드 다음에 공백이 없는지 확인하십시오.

An invalid XML character (Unicode: 0x5c) was found in the public identifier.

"공용 식별자가"후 나타나는 문자열입니다