When i call one of the WSDL operation from a spring project, i am getting following exception -
com.sun.istack.internal.SAXException2: unable to marshal type "com.pkg.wsdl.ABC" as an element because it is missing an @XmlRootElement annotation
I am using following in pom.xml to generate java objects from a WSDL(already used by many clients) as part of a spring project -
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
Looking at similar issue resolution i changed the code to use JAXBElement but still getting same error -
ABC vabc = new ABC();
vabc.set(..) // populate vabc object
ObjectFactory of = new ObjectFactory();
JAXBElement<ABC> jabc = of.createABC(vabc);
ABC oabc = jabc .getValue();
Marshaller Code -
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.pkg.wsdl");
and Calling the backend Web Service -
ABCResp response = (ABCResp) getWebServiceTemplate()
.marshalSendAndReceive("http://host:port/svcname",oabc);