public static <T> T xmlToBean(String xml, Class<T> clazz) throws JAXBException
{
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller um = context.createUnmarshaller();
StringReader sr = new StringReader(xml);
return (T)(um.unmarshal(sr));
}
public static String objectToXML(Object object) throws JAXBException
{
String xml = "";
JAXBContext context = JAXBContext.newInstance(object.getClass());
Marshaller m =context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
Writer w = new StringWriter();
m.marshal(object, w);
xml = w.toString();
return xml;
}
package com.syswinsoft.roc.bussiness.finance.bill.center.feign.web.dto.taxcontrol;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="business")
public class InvoiceOpener
{
@XmlAttribute(name="id")
private String id = "10008";
@XmlAttribute(name="comment")
private String comment = "发票开具";
@XmlElement(name="body")
private InvoiceOpenerBody body;
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getComment()
{
return comment;
}
public void setComment(String comment)
{
this.comment = comment;
}
public InvoiceOpenerBody getBody()
{
return body;
}
public void setBody(InvoiceOpenerBody body)
{
this.body = body;
}
}
package com.syswinsoft.roc.bussiness.finance.bill.center.feign.web.dto.taxcontrol;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
@XmlAccessorType(XmlAccessType.FIELD)
public class InvoiceOpenerBody
{
@XmlAttribute(name="yylxdm")
private String yylxdm = "1";
@XmlElement(name="kpzdbs")
private String kpzdbs;
@XmlElement(name="fplxdm")
private String fplxdm;
@XmlElement(name="kplx")
private String kplx;
@XmlElement(name="fpqqlsh")
private String fpqqlsh;
@XmlElement(name="tspz")
private String tspz;
@XmlElement(name="xhdwsbh")
private String xhdwsbh;
@XmlElement(name="xhdwmc")
private String xhdwmc;
@XmlElement(name="xhdwdzdh")
private String xhdwdzdh;
@XmlElement(name="xhdwyhzh")
private String xhdwyhzh;
@XmlElement(name="ghdwsbh")
private String ghdwsbh;
@XmlElement(name="ghdwmc")
private String ghdwmc;
@XmlElement(name="ghdwdzdh")
private String ghdwdzdh;
@XmlElement(name="ghdwyhzh")
private String ghdwyhzh;
@XmlElement(name="qdbz")
private String qdbz;
@XmlElement(name="zsfs")
private String zsfs;
@XmlElementWrapper(name="fyxm")
@XmlElement(name="group")
private List<InvoiceOpenerGroup> invoiceOpenerGroupList;
@XmlElement(name="hjje")
private String hjje;
@XmlElement(name="hjse")
private String hjse;
@XmlElement(name="jshj")
private String jshj;
@XmlElement(name="kce")
private String kce;
@XmlElement(name="bz")
private String bz;
@XmlElement(name="skr")
private String skr;
@XmlElement(name="fhr")
private String fhr;
@XmlElement(name="kpr")
private String kpr;
@XmlElement(name="tzdbh")
private String tzdbh;
@XmlElement(name="yfpdm")
private String yfpdm;
@XmlElement(name="yfphm")
private String yfphm;
public String getYylxdm()
{
return yylxdm;
}
public void setYylxdm(String yylxdm)
{
this.yylxdm = yylxdm;
}
public String getKpzdbs()
{
return kpzdbs;
}
public void setKpzdbs(String kpzdbs)
{
this.kpzdbs = kpzdbs;
}
public String getFplxdm()
{
return fplxdm;
}
public void setFplxdm(String fplxdm)
{
this.fplxdm = fplxdm;
}
public String getKplx()
{
return kplx;
}
public void setKplx(String kplx)
{
this.kplx = kplx;
}
public String getFpqqlsh()
{
return fpqqlsh;
}
public void setFpqqlsh(String fpqqlsh)
{
this.fpqqlsh = fpqqlsh;
}
public String getTspz()
{
return tspz;
}
public void setTspz(String tspz)
{
this.tspz = tspz;
}
public String getXhdwsbh()
{
return xhdwsbh;
}
public void setXhdwsbh(String xhdwsbh)
{
this.xhdwsbh = xhdwsbh;
}
public String getXhdwmc()
{
return xhdwmc;
}
public void setXhdwmc(String xhdwmc)
{
this.xhdwmc = xhdwmc;
}
public String getXhdwdzdh()
{
return xhdwdzdh;
}
public void setXhdwdzdh(String xhdwdzdh)
{
this.xhdwdzdh = xhdwdzdh;
}
public String getXhdwyhzh()
{
return xhdwyhzh;
}
public void setXhdwyhzh(String xhdwyhzh)
{
this.xhdwyhzh = xhdwyhzh;
}
public String getGhdwsbh()
{
return ghdwsbh;
}
public void setGhdwsbh(String ghdwsbh)
{
this.ghdwsbh = ghdwsbh;
}
public String getGhdwmc()
{
return ghdwmc;
}
public void setGhdwmc(String ghdwmc)
{
this.ghdwmc = ghdwmc;
}
public String getGhdwdzdh()
{
return ghdwdzdh;
}
public void setGhdwdzdh(String ghdwdzdh)
{
this.ghdwdzdh = ghdwdzdh;
}
public String getGhdwyhzh()
{
return ghdwyhzh;
}
public void setGhdwyhzh(String ghdwyhzh)
{
this.ghdwyhzh = ghdwyhzh;
}
public String getQdbz()
{
return qdbz;
}
public void setQdbz(String qdbz)
{
this.qdbz = qdbz;
}
public String getZsfs()
{
return zsfs;
}
public void setZsfs(String zsfs)
{
this.zsfs = zsfs;
}
public List<InvoiceOpenerGroup> getInvoiceOpenerGroupList()
{
return invoiceOpenerGroupList;
}
public void setInvoiceOpenerGroupList(List<InvoiceOpenerGroup> invoiceOpenerGroupList)
{
this.invoiceOpenerGroupList = invoiceOpenerGroupList;
}
public String getHjje()
{
return hjje;
}
public void setHjje(String hjje)
{
this.hjje = hjje;
}
public String getHjse()
{
return hjse;
}
public void setHjse(String hjse)
{
this.hjse = hjse;
}
public String getJshj()
{
return jshj;
}
public void setJshj(String jshj)
{
this.jshj = jshj;
}
public String getKce()
{
return kce;
}
public void setKce(String kce)
{
this.kce = kce;
}
public String getBz()
{
return bz;
}
public void setBz(String bz)
{
this.bz = bz;
}
public String getSkr()
{
return skr;
}
public void setSkr(String skr)
{
this.skr = skr;
}
public String getFhr()
{
return fhr;
}
public void setFhr(String fhr)
{
this.fhr = fhr;
}
public String getKpr()
{
return kpr;
}
public void setKpr(String kpr)
{
this.kpr = kpr;
}
public String getTzdbh()
{
return tzdbh;
}
public void setTzdbh(String tzdbh)
{
this.tzdbh = tzdbh;
}
public String getYfpdm()
{
return yfpdm;
}
public void setYfpdm(String yfpdm)
{
this.yfpdm = yfpdm;
}
public String getYfphm()
{
return yfphm;
}
public void setYfphm(String yfphm)
{
this.yfphm = yfphm;
}
}