I'm attempting to parse a generated .xml report from ReadyAPI through unmarshalling but am having trouble building out the classes. My example is much more complex then most of the research I have done online so it is hard for me to compare them. Could anyone help me build the object structure for something like this?
Example.xml
<testSuiteResults>
<testSuite>
<startTime>00:00:00</startTime>
<status>PASS</status>
<testSuiteName>Example Test Suite Name</testSuiteName>
<timeTaken>246</timeTaken>
<testRunnerResults>
<testCase>
<startTime>00:00:00</startTime>
<status>PASS</status>
<testCaseId>111aaa111aaa111aaa111</testCaseId>
<testCaseName>Example TestCase Name</testCaseName>
<timeTaken>123</timeTaken>
<testStepResults>
<result>
<message>Example Message</message>
<name>Example Result Name</name>
<order>1</order>
<started>00:00:00</started>
<status>PASS</status>
<timeTaken>123</timeTaken>
</result>
</testStepResults>
<testStepParameters>
<parameters>
<iconPath>/icon_path.png</iconPath>
<testStepName>Example Test</testStepName>
</parameters>
</testStepParameters>
</failedTestSteps>
</testCase>
<testCase>
<reason>Example Fail Reason</reason>
<startTime>00:00:00</startTime>
<status>FAIL</status>
<testCaseId>123abc123abc123abc123</testCaseId>
<testCaseName>Example Test Case Name 2</testCaseName>
<timeTaken>123</timeTaken>
<testStepResults>
<result>
<message>Example Message 2</message>
<name>Example Test Step Name 2</name>
<order>1</order>
<started>00:00:00</started>
<status>FAIL</status>
<timeTaken>123</timeTaken>
</result>
</testStepResults>
<testStepParameters>
<parameters>
<iconPath>/icon_path_2.png</iconPath>
<testStepName>Example Test Step Name 2</testStepName>
</parameters>
</testStepParameters>
<failedTestSteps>
<error>
<detail>Example Detail</detail>
<icon>icon.png</icon>
<testCaseName>Example Test Case Name 2</testCaseName>
<testStepName>Example Test Step Name 2</testStepName>
<testSuiteName>Example Test Suite Name</testSuiteName>
</error>
</failedTestSteps>
</testCase>
</testRunnerResults>
</testSuite>
</testSuiteResults>
After many iterations I have landed on this structure:
#XmlRootElement(name = "testSuiteResults")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestSuiteResults {
#XmlElement(name = "testSuite")
private List<TestSuite> testSuites;
public void setTestSuites(List<TestSuite> testSuites) {
this.testSuites = testSuites;
}
public List<TestSuite> getTestSuites() {
return this.testSuites;
}
public boolean hasTestSuites() {
return this.testSuites != null && this.testSuites.size() > 0;
}
}
#XmlRootElement(name = "testSuite")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestSuite {
#XmlElement(name = "startTime")
private String startTime;
#XmlElement(name = "status")
private String status;
#XmlElement(name = "testSuiteName")
private String testSuiteName;
#XmlElement(name = "timeTaken")
private String timeTaken;
#XmlElementWrapper(name = "testRunnerResults")
#XmlElement(name = "testCase", type = TestCase.class)
private List<TestCase> testRunnerResults;
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public void setStatus(String status) {
this.status = status;
}
public void setTestSuiteName(String testSuiteName) {
this.testSuiteName = testSuiteName;
}
public void setTimeTaken(String timeTaken) {
this.timeTaken = timeTaken;
}
public void setTestRunnerResults(List<TestCase> testRunnerResults) {
this.testRunnerResults = testRunnerResults;
}
public String getTestSuitename() {
return this.testSuiteName;
}
public List<TestCase> getTestCases() {
return this.testRunnerResults;
}
public boolean hasTestCases() {
return this.testRunnerResults != null;
}
}
#XmlRootElement(name = "testCase")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestCase {
#XmlElement(name = "reason")
private String reason;
#XmlElement(name = "startTime")
private String startTime;
#XmlElement(name = "status")
private String status;
#XmlElement(name = "testCaseId")
private String testCaseId;
#XmlElement(name = "testCaseName")
private String testCaseName;
#XmlElement(name = "timeTaken")
private String timeTaken;
#XmlElementWrapper(name = "testStepResults")
#XmlElement(name = "result")
private List<TestStepResult> testStepResults;
#XmlElementWrapper(name = "testStepParameters")
#XmlElement(name = "parameters")
private List<TestStepParameter> testStepParameters;
#XmlElementWrapper(name = "failedTestSteps")
#XmlElement(name = "error")
private List<TestStepError> failedTestSteps;
public void setReason(String reason) {
this.reason = reason;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public void setStatus(String status) {
this.status = status;
}
public void setTestCaseId(String testCaseId) {
this.testCaseId = testCaseId;
}
public void setTestCaseName(String testCaseName) {
this.testCaseName = testCaseName;
}
public void setTimeTaken(String timeTaken) {
this.timeTaken = timeTaken;
}
public void setTestStepResults(List<TestStepResult> testStepResults) {
this.testStepResults = testStepResults;
}
public void setTestStepParameters(List<TestStepParameter> testStepParameters) {
this.testStepParameters = testStepParameters;
}
public void setFailedTestSteps(List<TestStepError> failedTestSteps) {
this.failedTestSteps = failedTestSteps;
}
public String getReason() {
return this.reason;
}
public String getStartTime() {
return this.startTime;
}
public String getStatus() {
return this.status;
}
public String getTestCaseId() {
return this.testCaseId;
}
public String getTestCaseName() {
return this.testCaseName;
}
public String getTimeTaken() {
return this.timeTaken;
}
public List<TestStepResult> getTestStepResults() {
return this.testStepResults;
}
public List<TestStepParameter> getTestStepParameters() {
return this.testStepParameters;
}
public List<TestStepError> getFailedTestSteps() {
return this.failedTestSteps;
}
}
#XmlRootElement(name = "result")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestStepResult {
#XmlElement(name = "message")
private String message;
#XmlElement(name = "name")
private String testStepName;
#XmlElement(name = "order")
private int order;
#XmlElement(name = "started")
private String started;
#XmlElement(name = "status")
private String status;
#XmlElement(name = "timeTaken")
private String timeTaken;
public void setMessage(String message) {
this.message = message;
}
public void setTestStepName(String testStepName) {
this.testStepName = testStepName;
}
public void setOrder(int order) {
this.order = order;
}
public void setStarted(String started) {
this.started = started;
}
public void setStatus(String status) {
this.status = status;
}
public void setTimeTaken(String timeTaken) {
this.timeTaken = timeTaken;
}
public String getTestStepName() {
return this.testStepName;
}
}
#XmlRootElement(name = "paramters")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestStepParameter {
#XmlElement(name = "iconPath")
private String iconPath;
#XmlElement(name = "testStepName")
private String testStepName;
public void setIconPath(String iconPath) {
this.iconPath = iconPath;
}
public void setTestStepName(String testStepName) {
this.testStepName = testStepName;
}
public String getTestStepName() {
return this.testStepName;
}
}
#XmlRootElement(name = "error")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestStepError {
#XmlElement(name = "detail")
private String detail;
#XmlElement(name = "icon")
private String icon;
#XmlElement(name = "testCaseName")
private String testCaseName;
#XmlElement(name = "testStepName")
private String testStepName;
#XmlElement(name = "testSuiteName")
private String testSuiteName;
public void setDetail(String detail) {
this.detail = detail;
}
public void setIcon(String icon) {
this.icon = icon;
}
public void setTestCaseName(String testCaseName) {
this.testCaseName = testCaseName;
}
public void setTestStepName(String testStepName) {
this.testStepName = testStepName;
}
public void setTestSuiteName(String testSuiteName) {
this.testSuiteName = testSuiteName;
}
}
The Example.xml is how the report is generated, I have begun attempting to marshal it myself using sample data to confirm I am building this correctly. I've been able to get this response:
<testSuiteResults>
<testSuite>
<startTime>00:00:00</startTime>
<status>PASS</status>
<testSuiteName>TestSuiteName</testSuiteName>
<timeTaken>123</timeTaken>
<testRunnerResults/>
</testSuite>
</testSuiteResults>
It always stops on populating testRunnerResults, so I've attempted to look into XmlAdapters but I have had a lot of trouble understanding how to work it into this structure.
I am a novice in SAXParser. I don't know is it possible to parse complex object with SAXParser. I have a class which contain Item list. And my response xml is like that :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetPaymentServiceInfoResponse xmlns="http://quetzalcoatlus/EpulPaymentService"><GetPaymentServiceInfoResult><ResultCodes>OK</ResultCodes><Description>User is temporary blocked</Description><Items><Item><Amount>122</Amount></Item><Item><Amount>23232</Amount></Item></Items></GetPaymentServiceInfoResult></GetPaymentServiceInfoResponse></s:Body></s:Envelope>
And my POJO class is like following:
#XmlRootElement(name = "PGResponse")
public class CheckAbonSuccessResponseModel {
private String message;
private String message_code;
private BigDecimal amount;
private String invoiceCode;
private String operationCode;
private List<Item> items;
#XmlElement(name = "message")
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
#XmlElement(name = "message_code")
public String getMessage_code() {
return message_code;
}
public void setMessage_code(String message_code) {
this.message_code = message_code;
}
#XmlElement(name = "amount")
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
#XmlElement(name = "invoice_code")
public String getInvoiceCode() {
return invoiceCode;
}
public void setInvoiceCode(String invoiceCode) {
this.invoiceCode = invoiceCode;
}
#XmlElement(name = "operation_code")
public String getOperationCode() {
return operationCode;
}
public void setOperationCode(String operationCode) {
this.operationCode = operationCode;
}
#XmlElement(name = "items")
public List<Item> getItems() {
return items;
}
public void setItems(List<Item> items) {
this.items = items;
}
#XmlRootElement(name = "item")
public static class Item {
private String label;
private String value;
#XmlElement(name = "label")
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
#XmlElement(name = "value")
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}
How I can parse my xml string to CheckAbonSuccessResponseModel. Is it possible or not? I was trying but it shows just amount inside Result element.I need just know how I must write DefaultHandler class.
Thanks in advance.
I'm trying to unmarshall XML to POJO VmML class to pass it throught our system. The POJO classes was created from dtd file using jaxb2 maven plugin. When I use feature camel-jaxb in karaf I was able to unmarshall XML file into object of class VmML without any problem, but for some reasons I have to pull back this approach, and finally I end up with camel-jacksonxml.
In the route now I'm using unmarshall tag as below.
<dataFormats>
<jacksonxml id="jack" unmarshalTypeName="com.company.generated.VmML"/>
</dataFormats>
<rest path="/service"
consumes="application/xml"
produces="text/plain">
<post uri="/requestXmlCfg"
type="com.company.generated.VmML"
outType="java.lang.String">
<route>
<unmarshal ref="jack"/>
<to uri="bean:messageProcessot?method=process"/>
</route>
</post>
</rest>
I want to emphasize that it works earlier without unmarshaling tag, when I use simple camel-jaxb feature.
Now I get the exception which appears here often, but in my case the solutions are not proper because the data is provided and I don't want to skip anything. The error is:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "ReportType" (class com.company.generated.CarrierReport), not marked as ignorable (3 known properties: "CarrierReportSnapshot", "CarrierReportHeader", "CarrierReportPeriod"])
at [Source: org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache#612e834b; line: 6, column: 42] (through reference chain: com.company.generated.VmML["CarrierReport"]->java.util.ArrayList[0]->com.company.generated.CarrierReport["ReportType"])
POJO classes was created bas on: http://www.vmml.org/spec/VmML_v0.1.dtd
And the XML is filled properly
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE VmML SYSTEM "http://www.vmml.org/spec/VmML_v0.1.dtd">
<VmML Version="0.1">
<CarrierReport>
<CarrierReportHeader>
<ReportType SystemReference="aa">VMML</ReportType>
<ReportTimestamp Timezone="0" TimeFormat="RFC822">Tue, 07 May 2013 15:21:14 %2B0000</ReportTimestamp>
<SenderId SystemReference="aa">aa</SenderId>
<ReceiverId SystemReference="aa">aa</ReceiverId>
<SystemSource>aa</SystemSource>
<SystemDestination>aa</SystemDestination>
</CarrierReportHeader>
<CarrierReportSnapshot>
<Event>
<EventHeader>
<EventTimestamp Timezone="0" TimeFormat="RFC822">Tue, 07 May 2013 15:21:14 %2B0000</EventTimestamp>
<EventCode SystemReference="aa">aa</EventCode>
<EventText>aa</EventText>
</EventHeader>
</Event>
</CarrierReportSnapshot>
</CarrierReport>
</VmML>
VMML class:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"carrierReport"
})
#XmlRootElement(name = "VmML")
public class VmML {
#XmlAttribute(name = "Version", required = true)
#XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected String version;
#XmlAttribute(name = "id")
#XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected String id;
#XmlElement(name = "CarrierReport", required = true)
protected List<CarrierReport> carrierReport;
public String getVersion() {
return version;
}
public void setVersion(String value) {
this.version = value;
}
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
public List<CarrierReport> getCarrierReport() {
if (carrierReport == null) {
carrierReport = new ArrayList<CarrierReport>();
}
return this.carrierReport;
}
}
CarrierReport class:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"carrierReportHeader",
"carrierReportSnapshot",
"carrierReportPeriod"
})
#XmlRootElement(name = "CarrierReport")
public class CarrierReport {
#XmlElement(name = "CarrierReportHeader", required = true)
protected CarrierReportHeader carrierReportHeader;
#XmlElement(name = "CarrierReportSnapshot")
protected CarrierReportSnapshot carrierReportSnapshot;
#XmlElement(name = "CarrierReportPeriod")
protected CarrierReportPeriod carrierReportPeriod;
public CarrierReportHeader getCarrierReportHeader() {
return carrierReportHeader;
}
public void setCarrierReportHeader(CarrierReportHeader value) {
this.carrierReportHeader = value;
}
public CarrierReportSnapshot getCarrierReportSnapshot() {
return carrierReportSnapshot;
}
public void setCarrierReportSnapshot(CarrierReportSnapshot value) {
this.carrierReportSnapshot = value;
}
public CarrierReportPeriod getCarrierReportPeriod() {
return carrierReportPeriod;
}
public void setCarrierReportPeriod(CarrierReportPeriod value) {
this.carrierReportPeriod = value;
}
}
ReportType
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"value"
})
#XmlRootElement(name = "ReportType")
public class ReportType {
#XmlAttribute(name = "SystemReference")
#XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected String systemReference;
#XmlValue
protected String value;
public String getSystemReference() {
return systemReference;
}
public void setSystemReference(String value) {
this.systemReference = value;
}
public String getvalue() {
return value;
}
public void setvalue(String value) {
this.value = value;
}
}
Vmml > Carier Report > Carier Report Header > ReportType class
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"reportType",
"reportTimestamp",
"senderId",
"receiverId",
"systemSource",
"systemDestination",
"missionId",
"missionName"
})
#XmlRootElement(name = "CarrierReportHeader")
public class CarrierReportHeader {
#XmlElement(name = "ReportType", required = true)
protected ReportType reportType;
#XmlElement(name = "ReportTimestamp", required = true)
protected ReportTimestamp reportTimestamp;
#XmlElement(name = "SenderId", required = true)
protected SenderId senderId;
#XmlElement(name = "ReceiverId")
protected ReceiverId receiverId;
#XmlElement(name = "SystemSource", required = true)
protected String systemSource;
#XmlElement(name = "SystemDestination")
protected String systemDestination;
#XmlElement(name = "MissionId")
protected MissionId missionId;
#XmlElement(name = "MissionName")
protected String missionName;
public ReportType getReportType() {
return reportType;
}
public void setReportType(ReportType value) {
this.reportType = value;
}
public ReportTimestamp getReportTimestamp() {
return reportTimestamp;
}
public void setReportTimestamp(ReportTimestamp value) {
this.reportTimestamp = value;
}
public SenderId getSenderId() {
return senderId;
}
public void setSenderId(SenderId value) {
this.senderId = value;
}
public ReceiverId getReceiverId() {
return receiverId;
}
public void setReceiverId(ReceiverId value) {
this.receiverId = value;
}
public String getSystemSource() {
return systemSource;
}
public void setSystemSource(String value) {
this.systemSource = value;
}
public String getSystemDestination() {
return systemDestination;
}
public void setSystemDestination(String value) {
this.systemDestination = value;
}
public MissionId getMissionId() {
return missionId;
}
public void setMissionId(MissionId value) {
this.missionId = value;
}
public String getMissionName() {
return missionName;
}
public void setMissionName(String value) {
this.missionName = value;
}
}
Jackson 2.2.3
First, please excuse the stupid mistakes, I'm on a disconnected network, so I had to retype manually)
I have the following XML:
<orgs>
<org name="Test1">
<item>a</item>
<item>b</item>
</org>
<org name="Test2">
<item>c</item>
<item>d</item>
<item>e</item>
</org>
</orgs>
I have the following class to parse this:
#XmlRootElement(name = "orgs")
#XmlAccessorType(XmlAccessType.FIELD)
public class XmlOrgElements {
private List<Org> orgs;
public List<Org> getOrgs() {
return orgs;
}
public void setOrg(List<Org> orgs) {
this.orgs = orgs;
}
public class Org {
#JacksonXmlProperty(isAttribute = true)
private String name;
private List<Item> items;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Item> getItems() {
return items;
}
public void setName(List<Item> items) {
this.items = items;
}
}
public class Item {
#JacksonXmlText
private String item;
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
}
}
But all I'm getting back is "orgs=null". Does anyone know why?
You need to enable unwrapped handling for lists; default is to use "wrapped" format. The best way to diagnose this problem is to start with Java objects, serialize as XML, and see what the output format is.
This gives an idea of how structure differs.
If you want to default to unwrapped style, you can use:
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
mapper.registerModule(module);
There is also an annotation #JacksonXmlElementWrapper:
public class Bean {
#JacksonXmlElementWrapper(useWrapping=false)
public List<Stuff> entry;
}
to change behavior on per-list-property basis.
Here is the answer for those reading along:
#JacksonXmlRootElement(localname = "orgs")
public class Orgs {
#JacksonXmlElementWrapper(useWrapping = false)
private List<Org> org;
public List<Org> getOrg() {
return org;
}
public void setOrg(List<Org> org) {
this.orgs = org;
}
public Orgs() {}
}
public class Org {
#JacksonXmlProperty(isAttribute = true)
private String name;
#JacksonXmlElementWrapper(useWrapping = false)
private List<String> item;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getItem() {
return item;
}
public void setItem(List<String> item) {
this.item = item;
}
}
I am working with JAXB for the first time, and am having some issues understanding what it wants me to do.
I've setup a class that will be part of a fairly large XML - this class will represent the "Header" section of the XML document.
package com.somecompany.jscentral.xml.integrator.soc;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.somecompany.jscentral.xml.AbstractXML;
#XmlRootElement(name = "Header")
#XmlAccessorType(XmlAccessType.NONE)
#XmlType(propOrder = {"OrderRoutine", "CreationDate", "CreationTime", "UserId", "CustomerNumber",
"OrderType", "Salesman", "Handler", "Warehouse", "PrimaryCurrency", "OrderNumber",
"Name", "OrderDate", "DeliveryAddressNumber", "ConfirmationAddressNumber", "FullName999",
"CompanyName999", "StreetAddress999Line1", "StreetAddress999Line2", "City999", "StateProvince999",
"PostCode999", "Country999", "Resale999", "InvoiceCustomerNumber", "CustomerReference",
"NumberOfInvoiceCopies", "Language", "VAT", "Backlog", "OrderDiscountPercent", "DiscountGroup",
"PriceCode", "StandardTextNumber", "HoldOrder", "TermsOfPayment", "CreditDays", "TermsOfDelivery",
"MannerOfTransport", "FreightFee", "PostageFee", "InsuranceFee", "AdministrationFee", "InvoiceFee",
"CustomersOrderNumberReference", "GoodsMarking", "HoldInvoice", "DeliveryAddressEngineer",
"DeliveryAddressLocation", "CountryDispatchedToArrivedFrom", "VATRegNumberOfDebtorAddr",
"NatureOfTransaction", "VATHandlingCode", "PortOfArrivalDispatch", "CountryOfTrader", "InternalOrder",
"ToWarehouse", "RouteId", "DepartureId", "DestinationId", "ShippingAgent", "ContactListCode",
"Salesman2", "CreationDate2", "Sequence", "DebtorNumber", "DebtorAddressNumber", "InvoiceAddressNumber",
"WebOrder", "Confirmed", "ClientIdentity"})
public class Header extends AbstractXML {
public Header() throws JAXBException {
super();
}
#XmlElement(name = "OrderRoutine", required = true)
private String orderRoutine;
public void setOrderRoutine(String orderRoutine) {
this.orderRoutine = orderRoutine;
}
public String getOrderRoutine() {
return this.orderRoutine;
}
#XmlElement(name = "CreationDate", required = false)
private String creationDate;
public void setCreationDate(String creationDate) {
this.creationDate = creationDate;
}
public String getCreationDate() {
return this.creationDate;
}
#XmlElement(name = "CreationTime", required = false)
private String creationTime;
public void setCreationTime(String creationTime) {
this.creationTime = creationTime;
}
public String getCreationTime() {
return this.creationTime;
}
#XmlElement(name = "UserId", required = false)
private String userId;
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return this.userId;
}
#XmlElement(name = "CustomerNumber", required = true)
private String customerNumber;
public void setCustomerNumber(String customerNumber) {
this.customerNumber = customerNumber;
}
public String getCustomerNumber() {
return this.customerNumber;
}
#XmlElement(name = "OrderType", required = true)
private String orderType;
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getOrderType() {
return this.orderType;
}
#XmlElement(name = "Salesman", required = true)
private String salesman;
public void setSalesman(String salesman) {
this.salesman = salesman;
}
public String getSalesman() {
return this.salesman;
}
#XmlElement(name = "Handler", required = true)
private String handler;
public void setHandler(String handler) {
this.handler = handler;
}
public String getHandler() {
return this.handler;
}
#XmlElement(name = "Warehouse", required = true)
private String warehouse;
public void setWarehouse(String warehouse) {
this.warehouse = warehouse;
}
public String getWarehouse() {
return this.warehouse;
}
#XmlElement(name = "PrimaryCurrency", required = true)
private String primaryCurrency;
public void setPrimaryCurrency(String primaryCurrency) {
this.primaryCurrency = primaryCurrency;
}
public String getPrimaryCurrency() {
return this.primaryCurrency;
}
#XmlElement(name = "OrderNumber", required = false)
private String orderNumber;
public void setOrderNumber(String orderNumber) {
this.orderNumber = orderNumber;
}
public String getOrderNumber() {
return this.orderNumber;
}
#XmlElement(name = "Name", required = false)
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
#XmlElement(name = "OrderDate", required = false)
private String orderDate;
public void setOrderDate(String orderDate) {
this.orderDate = orderDate;
}
public String getOrderDate() {
return this.orderDate;
}
#XmlElement(name = "DeliveryAddressNumber", required = false)
private String deliveryAddressNumber;
public void setDeliveryAddressNumber(String deliveryAddressNumber) {
this.deliveryAddressNumber = deliveryAddressNumber;
}
public String getDeliveryAddressNumber() {
return this.deliveryAddressNumber;
}
#XmlElement(name = "ConfirmationAddressNumber", required = false)
private String confirmationAddressNumber;
public void setConfirmationAddressNumber(String confirmationAddressNumber) {
this.confirmationAddressNumber = confirmationAddressNumber;
}
public String getConfirmationAddressNumber() {
return this.confirmationAddressNumber;
}
#XmlElement(name = "FullName999", required = true)
private String fullName999;
public void setFullName999(String fullName999) {
this.fullName999 = fullName999;
}
public String getFullName999() {
return this.fullName999;
}
#XmlElement(name = "CompanyName999", required = true)
private String companyName999;
public void setCompanyName999(String companyName999) {
this.companyName999 = companyName999;
}
public String getCompanyName999() {
return this.companyName999;
}
#XmlElement(name = "StreetAddress999Line1", required = true)
private String streetAddress999Line1;
public void setStreetAddress999Line1(String streetAddress999Line1) {
this.streetAddress999Line1 = streetAddress999Line1;
}
public String getStreetAddress999Line1() {
return this.streetAddress999Line1;
}
#XmlElement(name = "StreetAddress999Line2", required = true)
private String streetAddress999Line2;
public void setStreetAddress999Line2(String streetAddress999Line2) {
this.streetAddress999Line2 = streetAddress999Line2;
}
public String getStreetAddress999Line2() {
return this.streetAddress999Line2;
}
#XmlElement(name = "City999", required = true)
private String city999;
public void setCity999(String city999) {
this.city999 = city999;
}
public String getCity999() {
return this.city999;
}
#XmlElement(name = "StateProvince999", required = true)
private String stateProvince999;
public void setStateProvince999(String stateProvince999) {
this.stateProvince999 = stateProvince999;
}
public String getStateProvince999() {
return this.stateProvince999;
}
#XmlElement(name = "PostCode999", required = true)
private String postCode999;
public void setPostCode999(String postCode999) {
this.postCode999 = postCode999;
}
public String getPostCode999() {
return this.postCode999;
}
#XmlElement(name = "Country999", required = true)
private String country999;
public void setCountry999(String country999) {
this.country999 = country999;
}
public String getCountry999() {
return this.country999;
}
#XmlElement(name = "Resale999", required = false)
private String resale999;
public void setResale999(String resale999) {
this.resale999 = resale999;
}
public String getResale999() {
return this.resale999;
}
#XmlElement(name = "InvoiceCustomerNumber", required = false)
private String invoiceCustomerNumber;
public void setInvoiceCustomerNumber(String invoiceCustomerNumber) {
this.invoiceCustomerNumber = invoiceCustomerNumber;
}
public String getInvoiceCustomerNumber() {
return this.invoiceCustomerNumber;
}
#XmlElement(name = "CustomerReference", required = false)
private String customerReference;
public void setCustomerReference(String customerReference) {
this.customerReference = customerReference;
}
public String getCustomerReference() {
return this.customerReference;
}
#XmlElement(name = "NumberOfInvoiceCopies", required = false)
private String numberOfInvoiceCopies;
public void setNumberOfInvoiceCopies(String numberOfInvoiceCopies) {
this.numberOfInvoiceCopies = numberOfInvoiceCopies;
}
public String getNumberOfInvoiceCopies() {
return this.numberOfInvoiceCopies;
}
#XmlElement(name = "Language", required = false)
private String language;
public void setLanguage(String language) {
this.language = language;
}
public String getLanguage() {
return this.language;
}
#XmlElement(name = "VAT", required = false)
private String vat;
public void setVAT(String vat) {
this.vat = vat;
}
public String getVAT() {
return this.vat;
}
#XmlElement(name = "Backlog", required = false)
private String backlog;
public void setBacklog(String backlog) {
this.backlog = backlog;
}
public String getBacklog() {
return this.backlog;
}
#XmlElement(name = "OrderDiscountPercent", required = false)
private String orderDiscountPercent;
public void setOrderDiscountPercent(String orderDiscountPercent) {
this.orderDiscountPercent = orderDiscountPercent;
}
public String getOrderDiscountPercent() {
return this.orderDiscountPercent;
}
#XmlElement(name = "DiscountGroup", required = false)
private String discountGroup;
public void setDiscountGroup(String discountGroup) {
this.discountGroup = discountGroup;
}
public String getDiscountGroup() {
return this.discountGroup;
}
#XmlElement(name = "PriceCode", required = false)
private String priceCode;
public void setPriceCode(String priceCode) {
this.priceCode = priceCode;
}
public String getPriceCode() {
return this.priceCode;
}
#XmlElement(name = "StandardTextNumber", required = false)
private String standardTextNumber;
public void setStandardTextNumber(String standardTextNumber) {
this.standardTextNumber = standardTextNumber;
}
public String getStandardTextNumber() {
return this.standardTextNumber;
}
#XmlElement(name = "HoldOrder", required = false)
private String holdOrder;
public void setHoldOrder(String holdOrder) {
this.holdOrder = holdOrder;
}
public String getHoldOrder() {
return this.holdOrder;
}
#XmlElement(name = "TermsOfPayment", required = true)
private String termsOfPayment;
public void setTermsOfPayment(String termsOfPayment) {
this.termsOfPayment = termsOfPayment;
}
public String getTermsOfPayment() {
return this.termsOfPayment;
}
#XmlElement(name = "CreditDays", required = false)
private String creditDays;
public void setCreditDays(String creditDays) {
this.creditDays = creditDays;
}
public String getCreditDays() {
return this.creditDays;
}
#XmlElement(name = "TermsOfDelivery", required = false)
private String termsOfDelivery;
public void setTermsOfDelivery(String termsOfDelivery) {
this.termsOfDelivery = termsOfDelivery;
}
public String getTermsOfDelivery() {
return this.termsOfDelivery;
}
#XmlElement(name = "MannerOfTransport", required = true)
private String mannerOfTransport;
public void setMannerOfTransport(String mannerOfTransport) {
this.mannerOfTransport = mannerOfTransport;
}
public String getMannerOfTransport() {
return this.mannerOfTransport;
}
#XmlElement(name = "FreightFee", required = true)
private String freightFee;
public void setFreightFee(String freightFee) {
this.freightFee = freightFee;
}
public String getFreightFee() {
return this.freightFee;
}
#XmlElement(name = "PostageFee", required = false)
private String postageFee;
public void setPostageFee(String postageFee) {
this.postageFee = postageFee;
}
public String getPostageFee() {
return this.postageFee;
}
#XmlElement(name = "InsuranceFee", required = false)
private String insuranceFee;
public void setInsuranceFee(String insuranceFee) {
this.insuranceFee = insuranceFee;
}
public String getInsuranceFee() {
return this.insuranceFee;
}
#XmlElement(name = "AdministrationFee", required = false)
private String administrationFee;
public void setAdministrationFee(String administrationFee) {
this.administrationFee = administrationFee;
}
public String getAdministrationFee() {
return this.administrationFee;
}
#XmlElement(name = "InvoiceFee", required = false)
private String invoiceFee;
public void setInvoiceFee(String invoiceFee) {
this.invoiceFee = invoiceFee;
}
public String getInvoiceFee() {
return this.invoiceFee;
}
#XmlElement(name = "CustomersOrderNumberReference", required = true)
private String customersOrderNumberReference;
public void setCustomersOrderNumberReference(String customersOrderNumberReference) {
this.customersOrderNumberReference = customersOrderNumberReference;
}
public String getCustomersOrderNumberReference() {
return this.customersOrderNumberReference;
}
#XmlElement(name = "GoodsMarking", required = true)
private String goodsMarking;
public void setGoodsMarking(String goodsMarking) {
this.goodsMarking = goodsMarking;
}
public String getGoodsMarking() {
return this.goodsMarking;
}
#XmlElement(name = "HoldInvoice", required = false)
private String holdInvoice;
public void setcustomersOrderNumberReference(String holdInvoice) {
this.holdInvoice = holdInvoice;
}
public String getcustomersOrderNumberReference() {
return this.holdInvoice;
}
#XmlElement(name = "DeliveryAddressEngineer", required = false)
private String deliveryAddressEngineer;
public void setDeliveryAddressEngineer(String deliveryAddressEngineer) {
this.deliveryAddressEngineer = deliveryAddressEngineer;
}
public String getDeliveryAddressEngineer() {
return this.deliveryAddressEngineer;
}
#XmlElement(name = "DeliveryAddressLocation", required = false)
private String deliveryAddressLocation;
public void setDeliveryAddressLocation(String deliveryAddressLocation) {
this.deliveryAddressLocation = deliveryAddressLocation;
}
public String getDeliveryAddressLocation() {
return this.deliveryAddressLocation;
}
#XmlElement(name = "CountryDispatchedToArrivedFrom", required = false)
private String countryDispatchedToArrivedFrom;
public void setCountryDispatchedToArrivedFrom(String countryDispatchedToArrivedFrom) {
this.countryDispatchedToArrivedFrom = countryDispatchedToArrivedFrom;
}
public String getCountryDispatchedToArrivedFrom() {
return this.countryDispatchedToArrivedFrom;
}
#XmlElement(name = "VATRegNumberOfDebtorAddr", required = false)
private String vatRegNumberOfDebtorAddr;
public void setVATRegNumberOfDebtorAddr(String vatRegNumberOfDebtorAddr) {
this.vatRegNumberOfDebtorAddr = vatRegNumberOfDebtorAddr;
}
public String getVATRegNumberOfDebtorAddr() {
return this.vatRegNumberOfDebtorAddr;
}
#XmlElement(name = "NatureOfTransaction", required = false)
private String natureOfTransaction;
public void setNatureOfTransaction(String natureOfTransaction) {
this.natureOfTransaction = natureOfTransaction;
}
public String getNatureOfTransaction() {
return this.natureOfTransaction;
}
#XmlElement(name = "VATHandlingCode", required = false)
private String vatHandlingCode;
public void setVATHandlingCode(String vatHandlingCode) {
this.vatHandlingCode = vatHandlingCode;
}
public String getVATHandlingCode() {
return this.vatHandlingCode;
}
#XmlElement(name = "PortOfArrivalDispatch", required = false)
private String portOfArrivalDispatch;
public void setPortOfArrivalDispatch(String portOfArrivalDispatch) {
this.portOfArrivalDispatch = portOfArrivalDispatch;
}
public String getPortOfArrivalDispatch() {
return this.portOfArrivalDispatch;
}
#XmlElement(name = "CountryOfTrader", required = false)
private String countryOfTrader;
public void setCountryOfTrader(String countryOfTrader) {
this.countryOfTrader = countryOfTrader;
}
public String getCountryOfTrader() {
return this.countryOfTrader;
}
// ETC...
}
Here's the stack trace:
Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 142 counts of IllegalAnnotationExceptions
Property orderRoutine is present but not specified in #XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.orderRoutine
at com.somecompany.jscentral.xml.integrator.soc.Header
Property creationDate is present but not specified in #XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.creationDate
at com.somecompany.jscentral.xml.integrator.soc.Header
Property creationTime is present but not specified in #XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.creationTime
at com.somecompany.jscentral.xml.integrator.soc.Header
Property userId is present but not specified in #XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.userId
at com.somecompany.jscentral.xml.integrator.soc.Header
.. ETC ..
Property OrderRoutine appears in #XmlType.propOrder, but no such property exists. Maybe you meant orderRoutine?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property CreationDate appears in #XmlType.propOrder, but no such property exists. Maybe you meant creationDate?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property CreationTime appears in #XmlType.propOrder, but no such property exists. Maybe you meant creationTime?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
.. ETC ..
Property InvoiceAddressNumber appears in #XmlType.propOrder, but no such property exists. Maybe you meant invoiceAddressNumber?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property WebOrder appears in #XmlType.propOrder, but no such property exists. Maybe you meant webOrder?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property Confirmed appears in #XmlType.propOrder, but no such property exists. Maybe you meant confirmed?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property ClientIdentity appears in #XmlType.propOrder, but no such property exists. Maybe you meant clientIdentity?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at com.somecompany.jscentral.xml.AbstractXML.<init>(AbstractXML.java:21)
at com.somecompany.jscentral.xml.integrator.soc.Header.<init>(Header.java:33)
at com.somecompany.jscentral.xml.integrator.IntegratorSOCXML.main(IntegratorSOCXML.java:22)
I have tried different #XmlAccessorType's ... but no change. I have also tried annotating the methods with #XmlTransient and no difference. What am I doing wrong?
The propOrder is based on the field/property name and not the element name. If you make this change everything will work correctly.
http://blog.bdoughan.com/2012/02/jaxbs-xmltype-and-proporder.html
Also if you are going to annotate the fields you should specify #XmlAccessorType(XmlAccessType.FIELD) on your class.
http://blog.bdoughan.com/2011/06/using-jaxbs-xmlaccessortype-to.html
Also since I notice you have inheritance in your model you can't include inherited properties in the propOrder unless you mark the part class with #XmlTransient.
http://blog.bdoughan.com/2012/08/jaxbs-xmltransient-and-property-order.html