Getting Marshall result into String
You can do it like this :
CreateExemptionCertificate cc = ...;
JAXBContext context = JAXBContext.newInstance(CreateExemptionCertificate.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter sw = new StringWriter();
m.marshal(cc, sw);
String result = sw.toString();
Just now I have got the answer of my question from this post below:
I want to convert an output stream into String object
I need to use StringWriter to take XML String from Marshal method