Im using jaxb to generate XML Request. Below are all the code details. I have also tried the package-info thing, but it didn't worked for me. Like i want to add the namespace on each object XML tag.
Hope you guys got my point. Am i doing something wrong or something missing? or is this kind of thing is possible in JAXB Java.
Required Output
<ns0:CustomizedBundlesSubscriptionPortalResultMsg xmlns:ns0="http://www.herman.com/schemas/SubscriptionCustomizedBundles.xsd">
<ns1:ResultHeader xmlns:ns1="http://www.herman.pk/eil/common_service/types/common_types/v1">
<ns1:RequestID>1</ns1:RequestID>
<ns1:Timestamp>20180518160833</ns1:Timestamp>
</ns1:ResultHeader>
<ns0:CustomizedBundlesResponseMessage>
<ns0:AcctChgRec>
<ns1:AccountType xmlns:ns1="http://www.herman.com/bme/cbsinterface/common">2000</ns1:AccountType>
<ns1:BalanceId xmlns:ns1="http://www.herman.com/bme/cbsinterface/common">999000000016059109</ns1:BalanceId>
</ns0:AcctChgRec>
</ns0:CustomizedBundlesResponseMessage>
</ns0:CustomizedBundlesSubscriptionPortalResultMsg>
Output Im Getting
<ns0:CustomizedBundlesSubscriptionPortalResultMsg xmlns:ns1="http://www.herman.pk/eil/common_service/types/common_types/v1" xmlns:ns0="http://www.herman.com/schemas/SubscriptionCustomizedBundles.xsd" xmlns:ns3="http://www.herman.com/bme/cbsinterface/common">
<ns1:ResultHeader>
<ns1:RequestID>1</ns1:RequestID>
<ns1:Timestamp>20180518160833</ns1:Timestamp>
</ns1:ResultHeader>
<ns0:CustomizedBundlesResponseMessage>
<ns0:AcctChgRec>
<ns3:AccountType>2000</ns3:AccountType>
<ns3:BalanceId>999000000016059109</ns3:BalanceId>
</ns0:AcctChgRec>
</ns0:CustomizedBundlesResponseMessage>
</ns0:CustomizedBundlesSubscriptionPortalResultMsg>
Below is my JAXB Parent Java Object Class
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"resultHeader",
"customizedBundlesResponseMessage"
})
@XmlRootElement(name = "CustomizedBundlesSubscriptionPortalResultMsg")
public class CustomizedBundlesSubscriptionPortalResultMsg {
@XmlElement(name = "ResultHeader", namespace = "http://www.herman.pk/eil/common_service/types/common_types/v1")
protected ResultHeaderType resultHeader;
@XmlElement(name = "CustomizedBundlesResponseMessage")
protected CustomizedBundlesResponseMessage customizedBundlesResponseMessage;
}
Below is my inner JAXB Object Java Class
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"acctChgRec"
})
@XmlRootElement(name = "CustomizedBundlesResponseMessage")
public class CustomizedBundlesResponseMessage {
@XmlElement(name = "AcctChgRec")
protected List<AcctChgRecType> acctChgRec;
}
Below is my AcctChgRecType JAXB Object Class
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AcctChgRecType", propOrder = {
})
public class AcctChgRecType {
@XmlElement(name = "AccountType", required = true, nillable = true)
protected String accountType;
@XmlElement(name = "BalanceId", required = true, type = Long.class, nillable = true)
}