Reputation: 183
I am facing major problem in my project. we have 2 xsd's. One is request xsd and another is response xsd. I have created JAXB classes for both xsd's.
I pass the Request JAXB to service layer then i got response object. Now i want to unmarshall this response as per Response JAXB.
So pleas help me to resolve this issue in my project. It is more appreciable.
Regards Narsi
Upvotes: 0
Views: 320
Reputation: 51
The below code snippet will help you.
File file = new File("Customers.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(Customers.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Customers customers = (Customers) jaxbUnmarshaller.unmarshal(file);
You said you have got the output XML. so pass it in the place of customers.xml. You have also mentioned that you have created the java objects from the xsd. So pass that class name in place of Customers.class.
You dont have to import any new jars as all these classes are present in rt.jar
Hope this helps you.
Upvotes: 2