I am using spring boot. I have generated soap request / response objects using apache CXF.
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/...</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
I want to serialize the JAXB request object that I receive once the web service is executed back to xml to store it on disk for later reuse.
I have tried this:
JAXBContext context = JAXBContext.newInstance(instance.getClass().getPackage().getName());
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter sw = new StringWriter();
marshaller.marshal(instance, sw);
String xml = sw.toString();
But I get the error message below:
"unable to marshal type \"com.uk.services.consumer.schema.v4.search.searchresponse.QuotationSearchResponse\" as an element because it is missing an @XmlRootElement annotation"}
How do I serialize the objects created by apache CXF back to XML. I am using Spring Boot.
for reference the generated source from CXF looks like this.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "QuotationSearchResponse")
public class QuotationSearchResponse
extends CommonResponse
{
}