Is there any way to decide at runtime which java class I would like to Unmarshall the XML into?
I tried in this way Unmarshall code -
public Object unmarshallXml(String xmlReq, String className)
{
String myClass = className+".class";
Object instances = null;
try {
JAXBContext jc = JAXBContext.newInstance( myClass );
Unmarshaller u = jc.createUnmarshaller();
StringBuffer xmlStr = new StringBuffer( xmlReq );
StringReader strReader = new StringReader( xmlStr.toString() );
StreamSource strSource = new StreamSource(strReader);
Object o = u.unmarshal( strSource );
} catch (JAXBException e) {
e.printStackTrace();
}
return instances;
}
but got this error -
" javax.xml.bind.JAXBException: "LookupInstances.class" doesnt contain ObjectFactory.class or jaxb.index"
No comments:
Post a Comment