如何在Java中创建JAXBXML数组类型?
我正在构建一个API,并且我已经尝试与Postman一起创建一个新的“如何在Java中创建JAXBXML数组类型?,java,arrays,xml,jaxb,Java,Arrays,Xml,Jaxb,我正在构建一个API,并且我已经尝试与Postman一起创建一个新的“项目”,并且只接受“项目”,如下所示: 我的输出没有我想要的type=“array”。我想知道如何在java ou jaxb中手动或不将type=“array”设置为我的输出(这是打印xml输出的代码部分jaxbMarshaller.marshall(invoiceRec,System.out);) 所以这是我的输出现在是这样,我的目标是: <items> <item>
项目
”,并且只接受“项目
”,如下所示:
我的输出没有我想要的type=“array”
。我想知道如何在java ou jaxb中手动或不将type=“array”
设置为我的输出(这是打印xml输出的代码部分jaxbMarshaller.marshall(invoiceRec,System.out);
)
所以这是我的输出现在是这样,我的目标是:
<items>
<item>
<id>1162842</id>
<name>tatat2</name>
<description>1</description>
<unit_price>1.0</unit_price>
<unit>hour</unit>
</item>
<item>
<id>1163631</id>
<name>testItem2333</name>
<description>abc</description>
<unit_price>1.0</unit_price>
<unit>hour</unit>
</item>
</items>
它给我的是带有
的输出,不带数组的字段,如下所示:
<items type="array">
<item>
<id>1162842</id>
<name>tatat2</name>
<description>1</description>
<unit_price>1.0</unit_price>
<unit>hour</unit>
</item>
<item>
<id>1163631</id>
<name>testItem2333</name>
<description>abc</description>
<unit_price>1.0</unit_price>
<unit>hour</unit>
</item>
</items>
<items type="array">
<item>
<id>1162842</id>
<name>tatat2</name>
<description>1</description>
<unit_price>1.0</unit_price>
<unit>hour</unit>
</item>
<item>
<id>1163631</id>
<name>testItem2333</name>
<description>abc</description>
<unit_price>1.0</unit_price>
<unit>hour</unit>
</item>
</items>
1162842
塔塔特2
1.
1
小时
1163631
测试项目2333
abc
1
小时
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
我的课程是这样的:
//ITEMS++++++++++++++++++++++++++++++++++
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;
import org.hibernate.mapping.Array;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;
import javax.persistence.*;
@Entity
@Table(name = "items")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "items")
@XmlRootElement(name="items")
@XmlAccessorType(XmlAccessType.FIELD)
public class Items implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name="item")
private Item[] item;
public Item[] getItem() {
return item;
}
public void setItem(Item[] item) {
this.item = item;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "sum")
private Double sum;
@Column(name = "discount")
private Double discount;
@Column(name = "before_taxes")
private Double before_taxes;
@Column(name = "taxes")
private Double taxes;
@Column(name = "total")
private Double total;
@ManyToMany(mappedBy = "items")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Invoice> invoices = new HashSet<>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Double getSum() {
return sum;
}
public void setSum(Double sum) {
this.sum = sum;
}
public Double getDiscount() {
return discount;
}
public void setDiscount(Double discount) {
this.discount = discount;
}
public Double getBefore_taxes() {
return before_taxes;
}
public void setBefore_taxes(Double before_taxes) {
this.before_taxes = before_taxes;
}
public Double getTaxes() {
return taxes;
}
public void setTaxes(Double taxes) {
this.taxes = taxes;
}
public Double getTotal() {
return total;
}
public void setTotal(Double total) {
this.total = total;
}
public Set<Invoice> getInvoices() {
return invoices;
}
public void setInvoices(Set<Invoice> invoices) {
this.invoices = invoices;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Items items = (Items) o;
if(items.id == null || id == null) {
return false;
}
return Objects.equals(id, items.id);
}
@Override
public int hashCode() {
return Objects.hashCode(id);
}
@Override
public String toString() {
return "Items{" +
"id=" + id +
", sum='" + sum + "'" +
", discount='" + discount + "'" +
", before_taxes='" + before_taxes + "'" +
", taxes='" + taxes + "'" +
", total='" + total + "'" +
'}';
}
//ITEM++++++++++++++++++++++++++++++++++
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;
/**
* A Item.
*/
@Entity
@Table(name = "item")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "item")
@XmlRootElement(name="item")
@XmlAccessorType(XmlAccessType.FIELD)
public class Item implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@Column(name = "name", nullable = false)
private String name;
@NotNull
@Column(name = "description", nullable = false)
private String description;
@NotNull
@DecimalMin(value = "0")
@Column(name = "unit_price", nullable = false)
private Double unit_price;
@NotNull
@Column(name = "unit", nullable = false)
private String unit;
@Column(name = "quantity")
private Double quantity;
@Column(name = "discount")
private Double discount;
@Column(name = "subtotal")
private Double subtotal;
@Column(name = "tax_amount")
private Double tax_amount;
@Column(name = "discount_amount")
private Double discount_amount;
@Column(name = "total")
private Double total;
@ManyToOne
@NotNull
private Tax tax;
@ManyToMany(mappedBy = "items")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Invoice> invoices = new HashSet<>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Double getUnit_price() {
return unit_price;
}
public void setUnit_price(Double unit_price) {
this.unit_price = unit_price;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public Double getQuantity() {
return quantity;
}
public void setQuantity(Double quantity) {
this.quantity = quantity;
}
public Double getDiscount() {
return discount;
}
public void setDiscount(Double discount) {
this.discount = discount;
}
public Double getSubtotal() {
return subtotal;
}
public void setSubtotal(Double subtotal) {
this.subtotal = subtotal;
}
public Double getTax_amount() {
return tax_amount;
}
public void setTax_amount(Double tax_amount) {
this.tax_amount = tax_amount;
}
public Double getDiscount_amount() {
return discount_amount;
}
public void setDiscount_amount(Double discount_amount) {
this.discount_amount = discount_amount;
}
public Double getTotal() {
return total;
}
public void setTotal(Double total) {
this.total = total;
}
public Tax getTax() {
return tax;
}
public void setTax(Tax tax) {
this.tax = tax;
}
public Set<Invoice> getInvoices() {
return invoices;
}
public void setInvoices(Set<Invoice> invoices) {
this.invoices = invoices;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Item item = (Item) o;
if(item.id == null || id == null) {
return false;
}
return Objects.equals(id, item.id);
}
@Override
public int hashCode() {
return Objects.hashCode(id);
}
@Override
public String toString() {
return "Item{" +
"id=" + id +
", name='" + name + "'" +
", description='" + description + "'" +
", unit_price='" + unit_price + "'" +
", unit='" + unit + "'" +
", quantity='" + quantity + "'" +
", discount='" + discount + "'" +
", subtotal='" + subtotal + "'" +
", tax_amount='" + tax_amount + "'" +
", discount_amount='" + discount_amount + "'" +
", total='" + total + "'" +
'}';
}
}
//And the code to convert the items+++++++++++++++++++++++
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput( true );
conn.setRequestMethod(type);
conn.setRequestProperty("Content-Type", "application/xml");
conn.setRequestProperty("Accept", "application/xml");
conn.setRequestProperty("charset" , "utf-8");
JAXBContext jc = JAXBContext.newInstance(Invoice.class);
Marshaller jaxbMarshaller = jc.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true);
// jaxbMarshaller.marshal(invoiceRec, System.out);
//TODO get of ITEM SET (DONE)-> -> Item[] item (DONE)->Items.setItem(item) (DONE) -> Return ITEMS to invoiceRec (DONE) -> Remove items -> !!Item need to hide TAX!!(it gets automatically)
Boolean turOnTests = false;
Item[] arrayITEM = new Item[invoiceRec.getItem().size()+1];
int i =0;
for (Iterator<Item> it = invoiceRec.getItem().iterator(); it.hasNext(); ) {
Item f = it.next();
arrayITEM[i] = f; //GET ITEM into arrayITEM[]
arrayITEM[i].setTax(null); // !!SET TAX NULL!!
i++;
it.remove();
}
if(turOnTests)
for(int y=0; y!= arrayITEM.length;y++){
System.out.println("TEST2: TOTAL arrayITEM[]: " + arrayITEM[y]);
}
Items totalItems = new Items();
totalItems.setItem(arrayITEM);
Set<Items> invoiceReturn = new HashSet<Items>(); //Set á Items
invoiceReturn.add(totalItems);
if(turOnTests)
for (Iterator<Items> it = invoiceReturn.iterator(); it.hasNext(); ) {
Items f = it.next();
System.out.println("TEST3: Item on the invoiceReturn Items: " + f.getItem().length );
}
invoiceRec.setItems(invoiceReturn); //Return Items to invoiceRec
//___________________________________________________________________________________________________
jaxbMarshaller.marshal(invoiceRec, System.out);
jaxbMarshaller.marshal(invoiceRec, conn.getOutputStream());
//项目++++++++++++++++++++++++++++++++++
导入com.fasterxml.jackson.annotation.JsonIgnore;
导入org.hibernate.annotations.Cache;
导入org.hibernate.annotations.cacheconcurrency策略;
导入org.hibernate.annotations.Type;
导入org.hibernate.mapping.Array;
导入org.springframework.data.elasticsearch.annotations.Document;
导入javax.persistence.*;
导入javax.xml.bind.annotation.*;
导入java.io.Serializable;
导入java.util.HashSet;
导入java.util.Set;
导入java.util.Objects;
导入javax.persistence.*;
@实体
@表(name=“items”)
@缓存(用法=缓存并发策略。非严格读写)
@文件(indexName=“项目”)
@XmlRootElement(name=“items”)
@XmlAccessorType(XmlAccessType.FIELD)
公共类项实现可序列化{
私有静态最终长serialVersionUID=1L;
@xmlement(name=“item”)
私人物品[]物品;
公共项[]获取项(){
退货项目;
}
公共无效集合项(项[]项){
this.item=项目;
}
@身份证
@GeneratedValue(策略=GenerationType.AUTO)
私人长id;
@列(name=“sum”)
私人双和;
@列(name=“折扣”)
私人双折;
@列(name=“税前”)
税前私人双保险;
@列(name=“taxes”)
私人双重征税;
@列(name=“总计”)
私人双总;
@许多(mappedBy=“items”)
@杰索尼奥雷
@缓存(用法=缓存并发策略。非严格读写)
私有集发票=新HashSet();
公共长getId(){
返回id;
}
公共无效集合id(长id){
this.id=id;
}
公共双getSum(){
回报金额;
}
公共无效设置金额(双倍总和){
this.sum=sum;
}
公共双折{
退货折扣;
}
公共折扣(双倍折扣){
这个。折扣=折扣;
}
税前公共双重征税(){
税前收益;
}
税前公共收入(税前加倍){
此项。税前=税前;
}
公共双轴{
退税;
}
公共税(双重税){
这个。税=税;
}
公共双getTotal(){
返回总数;
}
公共空间集合总计(双倍总计){
这个.总计=总计;
}
公共集getInvoices(){
退回发票;
}
公共作废设置发票(设置发票){
此项。发票=发票;
}
@凌驾
公共布尔等于(对象o){
if(this==o){
返回true;
}
如果(o==null | | getClass()!=o.getClass()){
返回false;
}
项目=(项目)o;
if(items.id==null | | id==null){
返回false;
}
返回Objects.equals(id,items.id);
}
@凌驾
公共int hashCode(){
返回Objects.hashCode(id);
}
@凌驾
公共字符串toString(){
返回“项目{”+
“id=”+id+
,sum='+sum+''+
,折扣=“+”折扣+“”+
“,税前=”+“税前+””+
,taxes=“+taxes+”“+
,合计=“+total+”“+
'}';
}
//项目++++++++++++++++++++++++++++++++++
导入com.fasterxml.jackson.annotation.JsonIgnore;
导入org.hibernate.annotations.Cache;
导入org.hibernate.annotations.cacheconcurrency策略;
导入org.springframework.data.elasticsearch.annotations.Document;
导入javax.persistence.*;
导入javax.validation.constraints.*;
导入javax.xml.bind.annotation.XmlAccessType;
导入javax.xml.bind.annotation.XmlAccessorType;
导入javax.xml.bind.annotation.XmlRootElement;
导入java.io.Serializable;
导入java.util.HashSet;
导入java.util.Set;
导入java.util.Objects;
/**
*一项。
*/
@实体
@表(name=“item”)
@缓存(用法=缓存并发策略。非严格读写)
@文件(indexName=“项目”)
@XmlRootElement(name=“item”)
@XmlAccessorType(XmlAccessType.FIELD)
公共类项实现可序列化{
私有静态最终长serialVersionUID=1L;
@身份证
@GeneratedValue(策略=GenerationType.AUTO)
私人长id;
@NotNull
@列(name=“name”,nullable=false)
私有字符串名称;
@NotNull
@列(name=“description”,nullable=false)
私有字符串描述;
@NotNull
@小数点(value=“0”)
@列(name=“单价”,可空=假)
私人双单价;
@NotNull
@列(name=“unit”,null=false)
专用字符串单元;
@列(name=“quan
//ITEMS++++++++++++++++++++++++++++++++++
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;
import org.hibernate.mapping.Array;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;
import javax.persistence.*;
@Entity
@Table(name = "items")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "items")
@XmlRootElement(name="items")
@XmlAccessorType(XmlAccessType.FIELD)
public class Items implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name="item")
private Item[] item;
public Item[] getItem() {
return item;
}
public void setItem(Item[] item) {
this.item = item;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "sum")
private Double sum;
@Column(name = "discount")
private Double discount;
@Column(name = "before_taxes")
private Double before_taxes;
@Column(name = "taxes")
private Double taxes;
@Column(name = "total")
private Double total;
@ManyToMany(mappedBy = "items")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Invoice> invoices = new HashSet<>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Double getSum() {
return sum;
}
public void setSum(Double sum) {
this.sum = sum;
}
public Double getDiscount() {
return discount;
}
public void setDiscount(Double discount) {
this.discount = discount;
}
public Double getBefore_taxes() {
return before_taxes;
}
public void setBefore_taxes(Double before_taxes) {
this.before_taxes = before_taxes;
}
public Double getTaxes() {
return taxes;
}
public void setTaxes(Double taxes) {
this.taxes = taxes;
}
public Double getTotal() {
return total;
}
public void setTotal(Double total) {
this.total = total;
}
public Set<Invoice> getInvoices() {
return invoices;
}
public void setInvoices(Set<Invoice> invoices) {
this.invoices = invoices;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Items items = (Items) o;
if(items.id == null || id == null) {
return false;
}
return Objects.equals(id, items.id);
}
@Override
public int hashCode() {
return Objects.hashCode(id);
}
@Override
public String toString() {
return "Items{" +
"id=" + id +
", sum='" + sum + "'" +
", discount='" + discount + "'" +
", before_taxes='" + before_taxes + "'" +
", taxes='" + taxes + "'" +
", total='" + total + "'" +
'}';
}
//ITEM++++++++++++++++++++++++++++++++++
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;
/**
* A Item.
*/
@Entity
@Table(name = "item")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "item")
@XmlRootElement(name="item")
@XmlAccessorType(XmlAccessType.FIELD)
public class Item implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@Column(name = "name", nullable = false)
private String name;
@NotNull
@Column(name = "description", nullable = false)
private String description;
@NotNull
@DecimalMin(value = "0")
@Column(name = "unit_price", nullable = false)
private Double unit_price;
@NotNull
@Column(name = "unit", nullable = false)
private String unit;
@Column(name = "quantity")
private Double quantity;
@Column(name = "discount")
private Double discount;
@Column(name = "subtotal")
private Double subtotal;
@Column(name = "tax_amount")
private Double tax_amount;
@Column(name = "discount_amount")
private Double discount_amount;
@Column(name = "total")
private Double total;
@ManyToOne
@NotNull
private Tax tax;
@ManyToMany(mappedBy = "items")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Invoice> invoices = new HashSet<>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Double getUnit_price() {
return unit_price;
}
public void setUnit_price(Double unit_price) {
this.unit_price = unit_price;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public Double getQuantity() {
return quantity;
}
public void setQuantity(Double quantity) {
this.quantity = quantity;
}
public Double getDiscount() {
return discount;
}
public void setDiscount(Double discount) {
this.discount = discount;
}
public Double getSubtotal() {
return subtotal;
}
public void setSubtotal(Double subtotal) {
this.subtotal = subtotal;
}
public Double getTax_amount() {
return tax_amount;
}
public void setTax_amount(Double tax_amount) {
this.tax_amount = tax_amount;
}
public Double getDiscount_amount() {
return discount_amount;
}
public void setDiscount_amount(Double discount_amount) {
this.discount_amount = discount_amount;
}
public Double getTotal() {
return total;
}
public void setTotal(Double total) {
this.total = total;
}
public Tax getTax() {
return tax;
}
public void setTax(Tax tax) {
this.tax = tax;
}
public Set<Invoice> getInvoices() {
return invoices;
}
public void setInvoices(Set<Invoice> invoices) {
this.invoices = invoices;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Item item = (Item) o;
if(item.id == null || id == null) {
return false;
}
return Objects.equals(id, item.id);
}
@Override
public int hashCode() {
return Objects.hashCode(id);
}
@Override
public String toString() {
return "Item{" +
"id=" + id +
", name='" + name + "'" +
", description='" + description + "'" +
", unit_price='" + unit_price + "'" +
", unit='" + unit + "'" +
", quantity='" + quantity + "'" +
", discount='" + discount + "'" +
", subtotal='" + subtotal + "'" +
", tax_amount='" + tax_amount + "'" +
", discount_amount='" + discount_amount + "'" +
", total='" + total + "'" +
'}';
}
}
//And the code to convert the items+++++++++++++++++++++++
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput( true );
conn.setRequestMethod(type);
conn.setRequestProperty("Content-Type", "application/xml");
conn.setRequestProperty("Accept", "application/xml");
conn.setRequestProperty("charset" , "utf-8");
JAXBContext jc = JAXBContext.newInstance(Invoice.class);
Marshaller jaxbMarshaller = jc.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true);
// jaxbMarshaller.marshal(invoiceRec, System.out);
//TODO get of ITEM SET (DONE)-> -> Item[] item (DONE)->Items.setItem(item) (DONE) -> Return ITEMS to invoiceRec (DONE) -> Remove items -> !!Item need to hide TAX!!(it gets automatically)
Boolean turOnTests = false;
Item[] arrayITEM = new Item[invoiceRec.getItem().size()+1];
int i =0;
for (Iterator<Item> it = invoiceRec.getItem().iterator(); it.hasNext(); ) {
Item f = it.next();
arrayITEM[i] = f; //GET ITEM into arrayITEM[]
arrayITEM[i].setTax(null); // !!SET TAX NULL!!
i++;
it.remove();
}
if(turOnTests)
for(int y=0; y!= arrayITEM.length;y++){
System.out.println("TEST2: TOTAL arrayITEM[]: " + arrayITEM[y]);
}
Items totalItems = new Items();
totalItems.setItem(arrayITEM);
Set<Items> invoiceReturn = new HashSet<Items>(); //Set á Items
invoiceReturn.add(totalItems);
if(turOnTests)
for (Iterator<Items> it = invoiceReturn.iterator(); it.hasNext(); ) {
Items f = it.next();
System.out.println("TEST3: Item on the invoiceReturn Items: " + f.getItem().length );
}
invoiceRec.setItems(invoiceReturn); //Return Items to invoiceRec
//___________________________________________________________________________________________________
jaxbMarshaller.marshal(invoiceRec, System.out);
jaxbMarshaller.marshal(invoiceRec, conn.getOutputStream());