How to deal with invalid characters in a WS output when using CXF?

前端 未结 4 1517
感动是毒
感动是毒 2021-02-07 06:00

I\'m using Spring, CXF and Hibernate to build a WebService that perform search queries on a foreign database that I have read-only access.

The problem is that some entri

4条回答
  •  我寻月下人不归
    2021-02-07 06:34

    To achieve the desired behaviour and avoid exceptions being thrown, you'll have to extend the default Woodstoks factory com.ctc.wstx.stax.WstxOutputFactory with your own's, that's supposed only to overwrite the property com.ctc.wstx.outputInvalidCharHandler with an instance of com.ctc.wstx.api.InvalidCharHandler.ReplacingHandler. This handler takes as constructor argument the replacement char to the invalid ones. With your instance in hand, create a file named META-INF/services/javax.xml.stream.XMLOutputFactory and place inside it only the complete name of your implementation (make sure it'll be placed inside the META-INF/services directory in the resulting jar).

    You can find more details here.

    HTH!

提交回复
热议问题