Estou usando o jaxb para gerar a nota fiscal eletronica, até agora tudo certo, gerei as classes através dos xsd e wsld, gerei o xml, enviei para a receita, recebi o xml de resposta, mas quando vou fazer o unmarshal, o jaxb so faz do no raiz, os elementos vem todos nulos.
XML de Retorno:
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
"<retConsStatServ xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"1.07\">\n" +
"<tpAmb>2</tpAmb>\n" +
"<verAplic>1</verAplic>\n" +
"<cStat>107</cStat>\n" +
"<xMotivo>Serviço em operação</xMotivo>\n" +
"<cUF>52</cUF> \n" +
"<dhRecbto>2009-09-29T10:39:21</dhRecbto>\n" +
"<tMed>1</tMed>\n" +
"</retConsStatServ>";
Classe bean:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2009.08.31 at 04:04:08 PM BRT
//
package br.com.jnfe.pl005d;
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;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* Tipo Resultado da Consulta do Status do Serviço
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TRetConsStatServ", propOrder = {
"tpAmb",
"verAplic",
"cStat",
"xMotivo",
"cuf",
"dhRecbto",
"tMed",
"dhRetorno",
"xObs"
})
@XmlRootElement(name = "retConsStatServ", namespace = "http://www.portalfiscal.inf.br/nfe")
public class TRetConsStatServ {
@XmlElement(required = true)
protected String tpAmb;
@XmlElement(required = true)
protected String verAplic;
@XmlElement(required = true)
protected String cStat;
@XmlElement(required = true)
protected String xMotivo;
@XmlElement(name = "cUF", required = true)
protected String cuf;
@XmlElement(required = true)
protected XMLGregorianCalendar dhRecbto;
protected String tMed;
protected XMLGregorianCalendar dhRetorno;
protected String xObs;
@XmlAttribute(required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String versao;
/**
* Gets the value of the tpAmb property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTpAmb() {
return tpAmb;
}
public void setTpAmb(String value) {
this.tpAmb = value;
}
/**
* Gets the value of the verAplic property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVerAplic() {
return verAplic;
}
public void setVerAplic(String value) {
this.verAplic = value;
}
/**
* Gets the value of the cStat property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCStat() {
return cStat;
}
public void setCStat(String value) {
this.cStat = value;
}
/**
* Gets the value of the xMotivo property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getXMotivo() {
return xMotivo;
}
public void setXMotivo(String value) {
this.xMotivo = value;
}
/**
* Gets the value of the cuf property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCUF() {
return cuf;
}
public void setCUF(String value) {
this.cuf = value;
}
/**
* Gets the value of the dhRecbto property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getDhRecbto() {
return dhRecbto;
}
public void setDhRecbto(XMLGregorianCalendar value) {
this.dhRecbto = value;
}
/**
* Gets the value of the tMed property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTMed() {
return tMed;
}
public void setTMed(String value) {
this.tMed = value;
}
/**
* Gets the value of the dhRetorno property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getDhRetorno() {
return dhRetorno;
}
public void setDhRetorno(XMLGregorianCalendar value) {
this.dhRetorno = value;
}
/**
* Gets the value of the xObs property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getXObs() {
return xObs;
}
public void setXObs(String value) {
this.xObs = value;
}
/**
* Gets the value of the versao property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVersao() {
return versao;
}
public void setVersao(String value) {
this.versao = value;
}
}
unmarshal:
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true);
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document docs = builder.parse(new InputSource(new StringReader(toUnmarshal)));
return getUnmarshaller(contextClazz).unmarshal(docs, contextClazz);
Alguem tem alguma idéia do q acontece?