You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by cameluserr123 <va...@gmail.com> on 2016/11/17 12:16:09 UTC
Issues in XML to POJO conversion
I am trying a simple conversion of an XML file to a POJO from the below Camel
code.
@Component
public class MyApplication extends RouteBuilder {
@Override
public void configure() throws Exception {
JaxbDataFormat jaxbFormat = new JaxbDataFormat();
jaxbFormat.setContext(JAXBContext.newInstance(Itemobject.class));
jaxbFormat.setFilterNonXmlChars(true)
from ("file:data")
.setProperty("fileBody", simple("${body}"))
.log("Body before unmarshaling is ${body}")
.unmarshal(jaxbFormat) //pojo
.log("Body after unmarshalling ${body}"
.to("seda:KeeplatestMozart")
.end();
}
}
I was expecting a POJO output but I am still getting the output in XML
format as follows :
<Item>
<CreateTimestamp value="2014-01-24 04:17:57"/>
<MozartItemNumber value="1401450797"/>
<DPCI dept="243" class="26" deptDesc="something" classDesc="something26"
item="2921"/>
<WebClass value="314" description="something/>
<LaunchDate value="2005-12-29"/>
<PrimaryVendor value="71825"/>
<ItemDescription/>
<ItemStatus description="Active"/>
<CountryOfOrigin description="something"/>
<ManufacturerBrand description="something"/>
<VendorList>
<Vendor mfrStyleId="ELIZA-01-NAT-085" gmsVendorId="1162772"/>
<vendor mfrStyleId="ELIZA-01-NAT-085" gmsVendorId="1162772"/>
</VendorList>
<ParentInfo varParentDirItemNum="14131667"/>
<relationshipType value="VC"/>
<ItemMilestone itemCreateTS="2012-01-30 22:44:41.000000"/>
</Item>
Below is my Itemobject class :
public class Itemobject {
CreateTimestamp CreateTimestamp;
MozartItemNumber MozartItemNumber;
Dpci DPCI;
Webclass WebClass;
Subclass SubClass;
LaunchDate LaunchDate;
PrimaryVendor PrimaryVendor;
ItemDescription ItemDescription;
ItemStatus ItemStatus;
CountryOfOrigin CountryOfOrigin;
ManufacturerBrand ManufacturerBrand;
VendorList VendorList;
ParentInfo ParentInfo;
RelationshipType relationshipType;
Barcodelist Barcodelist;
ItemMilestone ItemMilestone;
public com.tgt.item.giwFeed.routes.utils.CreateTimestamp
getCreateTimestamp() {
return CreateTimestamp;
}
public void
setCreateTimestamp(com.tgt.item.giwFeed.routes.utils.CreateTimestamp
createTimestamp) {
CreateTimestamp = createTimestamp;
}
public com.tgt.item.giwFeed.routes.utils.MozartItemNumber
getMozartItemNumber() {
return MozartItemNumber;
}
public void
setMozartItemNumber(com.tgt.item.giwFeed.routes.utils.MozartItemNumber
mozartItemNumber) {
MozartItemNumber = mozartItemNumber;
}
public Dpci getDPCI() {
return DPCI;
}
public void setDPCI(Dpci DPCI) {
this.DPCI = DPCI;
}
public Webclass getWebClass() {
return WebClass;
}
public void setWebClass(Webclass webClass) {
WebClass = webClass;
}
public Subclass getSubClass() {
return SubClass;
}
public void setSubClass(Subclass subClass) {
SubClass = subClass;
}
public com.tgt.item.giwFeed.routes.utils.LaunchDate getLaunchDate() {
return LaunchDate;
}
public void setLaunchDate(com.tgt.item.giwFeed.routes.utils.LaunchDate
launchDate) {
LaunchDate = launchDate;
}
public com.tgt.item.giwFeed.routes.utils.PrimaryVendor
getPrimaryVendor() {
return PrimaryVendor;
}
public void
setPrimaryVendor(com.tgt.item.giwFeed.routes.utils.PrimaryVendor
primaryVendor) {
PrimaryVendor = primaryVendor;
}
public com.tgt.item.giwFeed.routes.utils.ItemDescription
getItemDescription() {
return ItemDescription;
}
public void
setItemDescription(com.tgt.item.giwFeed.routes.utils.ItemDescription
itemDescription) {
ItemDescription = itemDescription;
}
public com.tgt.item.giwFeed.routes.utils.ItemStatus getItemStatus() {
return ItemStatus;
}
public void setItemStatus(com.tgt.item.giwFeed.routes.utils.ItemStatus
itemStatus) {
ItemStatus = itemStatus;
}
public com.tgt.item.giwFeed.routes.utils.CountryOfOrigin
getCountryOfOrigin() {
return CountryOfOrigin;
}
public void
setCountryOfOrigin(com.tgt.item.giwFeed.routes.utils.CountryOfOrigin
countryOfOrigin) {
CountryOfOrigin = countryOfOrigin;
}
public com.tgt.item.giwFeed.routes.utils.ManufacturerBrand
getManufacturerBrand() {
return ManufacturerBrand;
}
public void
setManufacturerBrand(com.tgt.item.giwFeed.routes.utils.ManufacturerBrand
manufacturerBrand) {
ManufacturerBrand = manufacturerBrand;
}
public com.tgt.item.giwFeed.routes.utils.VendorList getVendorList() {
return VendorList;
}
public void setVendorList(com.tgt.item.giwFeed.routes.utils.VendorList
vendorList) {
VendorList = vendorList;
}
public com.tgt.item.giwFeed.routes.utils.ParentInfo getParentInfo() {
return ParentInfo;
}
public void setParentInfo(com.tgt.item.giwFeed.routes.utils.ParentInfo
parentInfo) {
ParentInfo = parentInfo;
}
public RelationshipType getRelationshipType() {
return relationshipType;
}
public void setRelationshipType(RelationshipType relationshipType) {
this.relationshipType = relationshipType;
}
public com.tgt.item.giwFeed.routes.utils.Barcodelist getBarcodelist() {
return Barcodelist;
}
public void setBarcodelist(com.tgt.item.giwFeed.routes.utils.Barcodelist
barcodelist) {
Barcodelist = barcodelist;
}
public com.tgt.item.giwFeed.routes.utils.ItemMilestone
getItemMilestone() {
return ItemMilestone;
}
public void
setItemMilestone(com.tgt.item.giwFeed.routes.utils.ItemMilestone
itemMilestone) {
ItemMilestone = itemMilestone;
}
}
What is it that I am doing wrong here? I will be doing further processing on
the POJO.
Thanks
--
View this message in context: http://camel.465427.n5.nabble.com/Issues-in-XML-to-POJO-conversion-tp5790204.html
Sent from the Camel Development mailing list archive at Nabble.com.