Java Ninja Chronicles By Norris Shelton

Things I learned in the pursuit of code

ou would normally marshall a JAXB object to it’s XML String form by something similar to:

marshaller.marshal(tloPersonSearchOutput, stringWriter);

This assumes that the object is annotated with the JAXB @XmlRootElement annotation. If it is not, then you have to create a root element for it, by something like:

marshaller.marshal(new JAXBElement<TLOGenericSearchInput>(new QName("", "rootTag"),
                                                          TLOGenericSearchInput.class,
                                                          searchInput),
                   stringWriter);

You have to create the root element for the object. In this case, the root element is going to be called “rootTag”.

March 13th, 2012

Posted In: Java, xml

Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

WP to LinkedIn Auto Publish Powered By : XYZScripts.com