a nested xml unmarshalling using jaxb - java

I have an xml structure as follows:
<?xml version="1.0" encoding="UTF-8"?>
<school>
<students>
<student>
<firstName>A</firstName>
<id>1</id>
<lastName>C</lastName>
<company>BCD</company>
<responsibilities>
<responsibility>Leader</responsibility>
<responsibility>Dancer</responsibility>
<responsibility>Reporter</responsibility>
</responsibilities>
</student>
<student>
<firstName>B</firstName>
<id>2</id>
<lastName>C</lastName>
<company>EFG</company>
<responsibilities>
<responsibility>Singer</responsibility>
</responsibilities>
</student>
</students>
<Teachers>
<Teacher>
<firstName>A</firstName>
<lastName>C</lastName>
<responsibilities>
<responsibility>English</responsibility>
<responsibility>Hindi</responsibility>
<responsibility>Softskills</responsibility>
</responsibilities>
</Teacher>
<Teacher>
<firstName>A</firstName>
<lastName>C</lastName>
<company>BCD</company>
<responsibilities>
<responsibility>Science</responsibility>
<responsibility>Math</responsibility>
</responsibilities>
</Teacher>
</Teachers>
</school>
I would want to dynamically parse all the objects and put it into a list.
I have created classes for school,students,student,teacher,teacehrs,responsibilities, responsibility.
These are shown below:
import lombok.Data;
#Data
#XmlRootElement(name="school")
public class School {
private List<Students> Students;
private List<Teachers> Teachers;
}
#Data
public class Students {
private List<Student> student;
}
#Data
public class Student {
private long Id;
private String firstName;
private String lastName;
private String company;
private Responsibilities Responsibilities;
}
#XmlAccessorType(XmlAccessType.PROPERTY)
public class Responsibilities {
public List<String> responsibility ;
}
public class Responsibility {
private String responsibility;
}
#Data
public class Teachers {
private List<Teacher> teacher;
}
public class Teacher {
private String firstName;
private String lastName;
private String company;
private Responsibilities Responsibilities;
}
Also i have the main parsing file, where i want to generically pass all the objects through the root tag (school).
public class ParsingXML {
public static void main(String[] args) {
// TODO Auto-generated method stub
List<School> Entries = new ArrayList<School>();
try {
File xmlFile = new File("Student.xml");
JAXBContext jaxbContext;
jaxbContext = JAXBContext.newInstance(School.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
School entries = (School) jaxbUnmarshaller.unmarshal(xmlFile);
Entries.add(entries);
/*
* for(Student s: students.getStudent()) { System.out.println(s); }
*/
}
catch (JAXBException e)
{
e.printStackTrace();
}
ListIterator<School> litr = Entries.listIterator();
System.out.println(Entries.size());
//System.out.println("\n Using list iterator");
while(litr.hasNext()){
System.out.println(litr.next());
}
}
}
I expect to get Teachers entries too.. But I get ony students here.
Output:
School(Students=[Students(student=[Student(Id=1, firstName=A, lastName=C, company=BCD, Responsibilities=Responsibilities(responsibility=[Leader, Dancer, Reporter])), Student(Id=2, firstName=B, lastName=C, company=EFG, Responsibilities=Responsibilities(responsibility=[Singer]))])], Teachers=null)
Please suggest me my mistakes and provide me some guidance here

The following code would work for you:
School.class
#XmlRootElement(name = "school")
#Data
#XmlAccessorType(XmlAccessType.FIELD)
public class School {
#XmlElementWrapper(name="students")
#XmlElement(name="student")
private List<Student> students;
#XmlElementWrapper(name="Teachers")
#XmlElement(name="Teacher")
private List<Teacher> responsibilities;
}
Teacher.class:
#Data
#XmlAccessorType(XmlAccessType.NONE)
public class Teacher {
#XmlElement(name="firstName")
private String firstName;
#XmlElement(name="lastName")
private String lastName;
#XmlElementWrapper(name="responsibilities")
#XmlElement(name="responsibility")
private List<String> responsibilities;
}
Student.class:
#Data
#XmlAccessorType(XmlAccessType.NONE)
public class Student {
#XmlElement(name="id")
private long Id;
#XmlElement(name="firstName")
private String firstName;
#XmlElement(name="lastName")
private String lastName;
#XmlElement(name="company")
private String company;
#XmlElementWrapper(name="responsibilities")
#XmlElement(name="responsibility")
private List<String> responsibilities;
}
Main.class:
public class Main {
public static void main(String[] args) throws JAXBException, XMLStreamException {
final InputStream inputStream = Main.class.getClassLoader().getResourceAsStream("students.xml");
final XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
final Unmarshaller unmarshaller = JAXBContext.newInstance(School.class).createUnmarshaller();
final School school = unmarshaller.unmarshal(xmlStreamReader, School.class).getValue();
System.out.println(school.toString());
Marshaller marshaller = JAXBContext.newInstance(School.class).createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(school, System.out);
}
}
Following is the output:
School(students=[Student(Id=1, firstName=A, lastName=C, company=BCD, responsibilities=[Leader, Dancer, Reporter]), Student(Id=2, firstName=B, lastName=C, company=EFG, responsibilities=[Singer])], responsibilities=[Teacher(firstName=A, lastName=C, responsibilities=[English, Hindi, Softskills]), Teacher(firstName=A, lastName=C, responsibilities=[Science, Math])])
<school>
<students>
<student>
<id>1</id>
<firstName>A</firstName>
<lastName>C</lastName>
<company>BCD</company>
<responsibilities>
<responsibility>Leader</responsibility>
<responsibility>Dancer</responsibility>
<responsibility>Reporter</responsibility>
</responsibilities>
</student>
<student>
<id>2</id>
<firstName>B</firstName>
<lastName>C</lastName>
<company>EFG</company>
<responsibilities>
<responsibility>Singer</responsibility>
</responsibilities>
</student>
</students>
<Teachers>
<Teacher>
<firstName>A</firstName>
<lastName>C</lastName>
<responsibilities>
<responsibility>English</responsibility>
<responsibility>Hindi</responsibility>
<responsibility>Softskills</responsibility>
</responsibilities>
</Teacher>
<Teacher>
<firstName>A</firstName>
<lastName>C</lastName>
<responsibilities>
<responsibility>Science</responsibility>
<responsibility>Math</responsibility>
</responsibilities>
</Teacher>
</Teachers>
</school>

Related

Annotation based XML Marshalling in Spring Boot

In my spring boot application, I have below DTO class
#Data
public clsss Feed {
private int id;
private String name;
private String title;
#Builder
#XmlRootElement(name = "feeds")
public static class Feeds {
#XmlElement(name = "feed")
#Singular
private List<Feed> feeds;
}
}
My config class as below
#Component
public class JacksonCustomizer implements Jackson2ObjectMapperBuilderCustomizer {
#Override
public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) {
jacksonObjectMapperBuilder.modulesToInstall(new JaxbAnnotationModule());
}
}
DAO class implementation as below
public Feeds getAll() {
String sqlQuery = "SELECT * FROM feed WHERE trash = 0";
return Feeds.builder().feeds(namedParameterJdbcTemplate.query(sqlQuery, new BeanPropertyRowMapper<>(Feed.class))).build();
}
Using my ReST API, XML response I am receiving as below:
<feeds>
<feed>
<feed>
<id>1</id>
<name>Val1</name>
<title>Title1</title>
</feed>
<feed>
<id>2</id>
<name>Val2</name>
<title>Title2</title>
</feed>
</feed>
</feeds>
I want to remove <feed> which comes as a wrapper element. Desired output is as below:
<feeds>
<feed>
<id>1</id>
<name>Val1</name>
<title>Title1</title>
</feed>
<feed>
<id>2</id>
<name>Val2</name>
<title>Title2</title>
</feed>
</feeds>
Make changes in the config class to set the default wrapper to false.
#Component
public class JacksonCustomizer implements Jackson2ObjectMapperBuilderCustomizer {
#Override
public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) {
jacksonObjectMapperBuilder.modulesToInstall(new JaxbAnnotationModule());
jacksonObjectMapperBuilder.defaultUseWrapper(false); //This was missing before
}
}

The output is showing error when I convert xml into java object using JAXBException

In src/main/java, I have POJO classes and in src/test/resource I have XML file. I'm writing a Junit test case where I have to parse the XML file into POJOs using JAXBException and then I have to check whether the variables are null or not.
I created a test class and added the asseertNotNull statement but after running the code as "Junit test" I'm getting some errors.
Java Class :-
package com.examples.demo;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
#XmlRootElement(name = "book")
// Defining order
#XmlType(propOrder = { "author", "name", "publisher", "isbn" })
public class Book {
private String name;
private String author;
private String publisher;
private String isbn;
// Changing to title
#XmlElement(name = "title")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#XmlAttribute(name = "AuthorName")
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
#XmlElement(name = "publisher")
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
#XmlElement(name = "isbn")
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
#Override
public String toString() {
final StringBuilder sb = new StringBuilder("Book{");
sb.append("name='").append(name).append('\'');
sb.append(", author='").append(author).append('\'');
sb.append(", publisher='").append(publisher).append('\'');
sb.append(", isbn='").append(isbn).append('\'');
sb.append('}');
return sb.toString();
}
}
Test Class :-
package com.examples.demo;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.io.StringReader;
import javax.xml.bind.JAXBException;
import org.junit.jupiter.api.Test;
import jakarta.xml.bind.JAXBContext;
public class BookTest {
private static final String BOOKSTORE_XML = "src/test/resources/bookstore.xml";
#Test
public void oneDemo() throws JAXBException, IOException, jakarta.xml.bind.JAXBException {
JAXBContext context = JAXBContext.newInstance(BookStore.class);
BookStore bookStore = (BookStore) context.createUnmarshaller().unmarshal(new StringReader(BOOKSTORE_XML));
String name = bookStore.getName();
assertNotNull(name);
}
}
XML file :-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:bookStore xmlns:ns2="com.zetcode">
<bookList>
<book AuthorName="Neil Strauss">
<title>The Game</title>
<publisher>Harpercollins</publisher>
<isbn>978-0060554736</isbn>
</book>
<book AuthorName="Charlotte Roche">
<title>Feuchtgebiete</title>
<publisher>Dumont Buchverlag</publisher>
<isbn>978-3832180577</isbn>
</book>
</bookList>
<location>Livres belles</location>
<name>Fraport Bookstore</name>
</ns2:bookStore>
How to solve this? please help me
Taking the xml you are using for tests (I omitted non significative tags from code, up to you integrate them):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:bookStore xmlns:ns2="com.zetcode">
<bookList>
<book AuthorName="Neil Strauss">
<title>The Game</title>
<publisher>Harpercollins</publisher>
<isbn>978-0060554736</isbn>
</book>
<book AuthorName="Charlotte Roche">
<title>Feuchtgebiete</title>
<publisher>Dumont Buchverlag</publisher>
<isbn>978-3832180577</isbn>
</book>
</bookList>
<location>Livres belles</location>
<name>Fraport Bookstore</name>
</ns2:bookStore>
The first problem is about the presence of <ns2:bookStore xmlns:ns2="com.zetcode"> tag, you have to define a BookStorewrapper class matching the <bookStore> tag to wrap the <bookList> tag using the XmlRootElement annotation:
#Data //<--lombok annotation
#XmlRootElement(name="bookStore", namespace = "com.zetcode")
#XmlAccessorType(XmlAccessType.FIELD) //<-- used for permit access to fields
public class BookStore {
public BookList bookList;
}
You have to repeat the same process for the bookList tag being aware it contains a list of books with the help of the XmlElement annotation which specifies every book is an element of the list:
#Data
#XmlRootElement(name="bookList")
#XmlAccessorType(XmlAccessType.FIELD)
public class BookList {
#XmlElement(name = "book")
private List<Book> books;
}
#Data
#XmlRootElement(name = "book")
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(propOrder = {"author", "name", "publisher", "isbn"})
public class Book {
private String name;
private String author;
private String publisher;
private String isbn;
}
Then you can verify that everything is ok unmarshalling and marshalling the xml, printing it to the stdout :
public class JaxbMain {
public static void main(String[] args) throws JAXBException {
File xml = new File("msg.xml");
//unmarshalling the xml
JAXBContext jc = JAXBContext.newInstance(BookStore.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
BookStore bookStore = (BookStore) unmarshaller.unmarshal(xml);
//marshalling the xml to the stdout
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//ok it prints the same xml
marshaller.marshal(bookStore, System.out);
}
}
Pom.xml:
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.4</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
</dependencies>

JSON to XML conversion using spring for Multiple models

I have a use case in which i get a JSON from a service and i need to create a custom XML out of it.
JSON we receive
[StudentDetails(Name=Lucky, Section=B, Subjects={}, StudentId=4, Hobies=MCCDDVP1, Principal=Mary),
StudentDetails(Name=Brendon, Section=A, Subjects={}, StudentId=1, Hobies=MCCDDVP1, Principal=Mary),
StudentDetails(Name=Gina, Section=A, Subjects={}, StudentId=2, Hobies=MCCDDVP1, Principal=Mary),
StudentDetails(Name=Monica, Section=A, Subjects={}, StudentId=3, Hobies=MCCDDVP1, Principal=Mary),
StudentDetails(Name=Stephen, Section=B, Subjects={}, StudentId=5, Hobies=MCCDDVP1, Principal=Mary),
StudentDetails(Name=Justin, Section=B, Subjects={}, StudentId=6, Hobies=MCCDDVP1, Principal=Mary),
StudentDetails(Name=Sony, Section=B, Subjects={}, StudentId=7, Hobies=MCCDDVP1, Principal=Mary)]
XML to create
<Class>
<Section>A
<Subject>Maths
<Student>Brendon
<Gender>M</Gender>
<RollNumber>1</RollNumber>
</Student>
<Student>Monica
<Gender>F</Gender>
<RollNumber>2</RollNumber>
</Student>
</Subject>
<Subject>English
<Student>Brendon
<Gender>M</Gender>
<RollNumber>1</RollNumber>
</Student>
<Student>Gina
<Gender>F</Gender>
<RollNumber>3</RollNumber>
</Student>
</Subject>
</Section>
<Section>B
<Subject>Science
<Student>Justin
<Gender>M</Gender>
<RollNumber>4</RollNumber>
</Student>
<Student>Sony
<Gender>F</Gender>
<RollNumber>2</RollNumber>
</Student>
</Subject>
<Subject>English
<Student>Stephen
<Gender>M</Gender>
<RollNumber>5</RollNumber>
</Student>
<Student>Lucky
<Gender>F</Gender>
<RollNumber>3</RollNumber>
</Student>
</Subject>
</Section>
<PrincipalName>Mary</PrincipalName>
</Class>
Now i did create the model class for each attribute like below
Class.java
#XmlRootElement
public class Class{
private List<Section> section;
public List<Section> getSection() {
return section;
}
#XmlElement
public void setSection(List<Section> section) {
this.section= section;
}
}
Section.java
public class Section{
private Subject subject;
public Subject getsubject() {
return section;
}
public void setsubject(Subject subject) {
this.subject= subject;
}
}
and so on for all the inner attributes.
Now i am not sure how to create the XML out of these models and get the values from the given JSON as per the XML we need to render using spring boot.
Below is the solution i tried
Created 2 more class just to start with.
Subject.java
public class Subject {
private Student student;
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public Subject(Student student) {
super();
this.student = student;
}
private Map<String, List<Student>> studentSubjectMap;
public Map<String, List<Student>> getstudentSubjectMap() {
return bPartnerEndPointMap;
}
public void setstudentSubjectMap(Map<String, List<Student>> studentSubjectMap) {
this.studentSubjectMap = studentSubjectMap;
}
}
Student.java
public class Student {
private String gender;
private int rollNumber
//Getter and Setter
//All Args constructor
}
From the json values i set the values in the classes and then tried to marshal the Class.java as below
Main.java
Subject subjectList = new Subject((Student.stream().collect(Collectors.groupingBy
(Student::getSubject,
Collectors.mapping(Student::getRollNumber,Collectors.toList())))));
Section section = new Section(subjectList);
Class class = new Class(section);
JAXBContext jc;
try {
jc = JAXBContext.newInstance(Class.class); // line #1
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(combinedXml, file);
m.marshal(combinedXml, System.out);
} catch (JAXBException e) {
log.error("Error while creating XML", e);
}
After doing this i am getting below error at line #1
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
Below are the ways i tried to set the values in the Pojo
a. Using #Builder
b. Using #Autowiring
c. Using "new" Keyword.
Getting the same error only number of annotations in error changes.
I am not sure what am i missing.
You need to
create a JAXBContext from your model class
Create a Marshaller from your JAXBContext; then
call the marshall method, passing in your model object
An example that will return an XML string is below...
public String getXMLString(Class obj) {
JAXBContext jc = JAXBContext.newInstance(Class.class)
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
StringWriter sw = new StringWriter();
m.marshal(obj, sw);
return sw.toString();
}

JAXB Marshalling extra element in XML

I have the following Employee class which i need to represent in XML format
Employee:
#XmlRootElement(name="employee")
#XmlAccessorType(XmlAccessType.FIELD)
public class Employee {
private int id;
private String firstName;
private String lastName;
private int income;
private Map<Integer,Employee> employeeMap=new HashMap<>();
//getters and setters
}
Marshalling code:
public class MarshallExample {
public static void main(String[] args) throws JAXBException {
Map<Integer,Employee> empMap=new HashMap<>();
Employee emp1=new Employee();
emp1.setId(1);
emp1.setFirstName("aa");
emp1.setLastName("bb");
emp1.setIncome(1000);
Employee emp2=new Employee();
emp2.setId(2);
emp2.setFirstName("xx");
emp2.setLastName("yy");
emp2.setIncome(2000);
empMap.put(1, emp1);
empMap.put(2, emp2);
Employee emp=new Employee();
emp.setEmployeeMap(empMap);
JAXBContext jaxbContext=JAXBContext.newInstance(Employee.class);
Marshaller jaxbMarshaller=jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(emp, System.out);
}
}
XML Output:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<employee>
<id>0</id>
<income>0</income>
<employeeMap>
<entry>
<key>1</key>
<value>
<id>1</id>
<firstName>aa</firstName>
<lastName>bb</lastName>
<income>1000</income>
<employeeMap/>
</value>
</entry>
<entry>
<key>2</key>
<value>
<id>2</id>
<firstName>xx</firstName>
<lastName>yy</lastName>
<income>2000</income>
<employeeMap/>
</value>
</entry>
</employeeMap>
</employee>
Not able to figure out why the <id> 0 </id> and <income> 0 </income> element are present in the output inside the root element instead of just the two employee instances.
It is because that are int values and can not be null. Change it to Integer an they will not longer rendered.
#XmlRootElement(name="employee")
#XmlAccessorType(XmlAccessType.FIELD)
public class Employee {
private Integer id;
private String firstName;
private String lastName;
private Integer income;
private Map<Integer,Employee> employeeMap=new HashMap<>();
//getters and Setters
}

Unmarshalling with complex type

I'm having trouble unmarshalling XML that represents an invoice in this form:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<Response xmlns="Lamp">
<Result>
<Title>The Title</Title>
<Lines>
<anyType xsi:type="InvoiceLine">
<Name>Name One</Name>
<Quantity>1.0000</Quantity>
</anyType>
<anyType xsi:type="InvoiceLine">
<Name>Name Two</Name>
<Quantity>2.0000</Quantity>
</anyType>
</Lines>
</Result>
</Response>
</soap:Body>
</soap:Envelope>
The Invoice class:
#XmlAccessorType(XmlAccessType.FIELD)
public class Invoice {
public String Title;
public List<InvoiceLine> Lines;
}
The InvoiceLine class:
#XmlAccessorType(XmlAccessType.FIELD)
public class InvoiceLine extends anyType {
public String Name;
public float quantity;
}
And a abstract class for anyType:
public abstract class anyType {}
This is the code I'm using to do the unmarshalling:
public static void main(String[] args) throws Exception {
InputStream is = new FileInputStream("input.xml");
XMLInputFactory xif = XMLInputFactory.newFactory();
XMLStreamReader xsr = xif.createXMLStreamReader(is);
xsr.nextTag();
while(!xsr.getLocalName().equals("Result")) {
xsr.nextTag();
}
JAXBContext jc = JAXBContext.newInstance(Invoice.class, InvoiceLine.class);
javax.xml.bind.Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<Invoice> jb = unmarshaller.unmarshal(xsr, Invoice.class);
xsr.close();
System.out.println(jb.getValue());
}
The problem is the Lines list only contains 1 entry with Name=null and quantity=0.0.
-- Edit:
I've just tried adding XmlElement and XmlElementWrapper annotations to both classes, the only change is that the Lines list has no elements.
Modified Invoice:
#XmlAccessorType(XmlAccessType.FIELD)
public class Invoice {
#XmlElement(name = "Title")
public String Title;
#XmlElement(name = "anyType")
#XmlElementWrapper(name = "Lines")
public List<InvoiceLine> Lines;
}
Modified InvoiceLine:
#XmlAccessorType(XmlAccessType.FIELD)
public class InvoiceLine extends anyType {
#XmlElement(name = "Name")
public String Name;
#XmlElement(name = "Quantity")
public float Quantity;
}
-- Edit:
I've just tried making the attributes lower case, but still no luck.

Categories