Set encoding of XML using Jaxb properties

encoding, jaxb, properties

Solution

Encoding for MOXy and all JAXB implementations is controlled by the `JAXB_ENCODING` property set on the `Marshaller`.

- http://blog.bdoughan.com/2011/08/jaxb-and-java-io-files-streams-readers.html

Problem

I configured my web service client to use `Moxy` to `marshall / unmarshall` the service payloads. My service client does not have a control on the `Jaxb configuration`. That said, I have configured my client to use `Moxy` by adding a `jaxb.properties` file with the entry as follows:: ``` javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory ``` I have a requirement to change the encoding of the payload so that its:: ``` <?xml version="1.0" encoding="windows-1252"?> ``` Is this possible by adding an entry to `jaxb.properties` (as it would be a lot of work for me to inject this value via code, due to the various frameworks we have in place).

Original source