1

私のアプリケーションは、Wink と JDK (1.6) に組み込まれている JAXB プロバイダーを使用して REST API をサポートしています。制御文字を含む PUT リクエストを受け取ることがあります。

私のアプリケーションに関する限り、制御文字は有効で意味のある入力を構成します。ただし、アプリケーションは、これらの文字を消化できないという悪名高い例外をスローします。

Message: An invalid XML character (Unicode: 0x13) was found in the element content of the document.]
at org.apache.wink.common.internal.providers.entity.xml.JAXBXmlProvider.readFrom(JAXBXmlProvider.java:107)
at org.apache.wink.server.internal.registry.ServerInjectableFactory$EntityParam.getValue(ServerInjectableFactory.java:190)
at org.apache.wink.common.internal.registry.InjectableFactory.instantiate(InjectableFactory.java:67)
at org.apache.wink.server.internal.handlers.CreateInvocationParametersHandler.handleRequest

JAXB プロバイダーにこれらの文字を無視するように指示する方法はおそらくありません (ある時点で Xml を解析する必要があり、違法は違法であるため..)。どうすればこれを機能させることができますか?Rest クライアントにこれらの文字を送信する前にエスケープするように指示する方法はありますか?

4

2 に答える 2

2

Control characters are not allowed in XML so your data is not XML. The trouble with it is like X except for Y is that it would be difficult to define an API where Y can be whatever the individual thinks it should be. It is unlikely JAXB will accommodate you. You could use a filter to strip the illegal characters if that is acceptable; otherwise you will have to encode or escape the data in legal character data (e.g. with Base64.)

于 2013-01-07T15:10:41.887 に答える
2

問題の文字は「印刷できない XML 文字」ではありません。これらは印刷できない非 XML 文字です。

于 2013-01-07T15:45:57.827 に答える