Boa noite povo.
Seguinte comecei a implementar e tals o meu sistema de NF-e, e para começar estou tentando o status.
A parte de validar a conexão com certificado ta beleza.
O problema é o JAXB com o JAX-WS que tao batendo cabeça.
Olha o codigo main que to usando para chamada:
… aqui seto os certificados… FUNCIONA normal
NfeCabecMsg cabecMsg = new ObjectFactory().createNfeCabecMsg();
cabecMsg.setCUF("35");
cabecMsg.setVersaoDados("2.00");
TConsStatServ dadosMsg = new ObjectFactory().createTConsStatServ();
dadosMsg.setCUF("35");
dadosMsg.setTpAmb("2");
dadosMsg.setVersao("2.00");
dadosMsg.setXServ("STATUS");
NfeDadosMsg dadosMsgE = new ObjectFactory().createNfeDadosMsg();
dadosMsgE.getContent().add(dadosMsg);
NfeStatusServico2Soap12 s = service.getNfeStatusServico2Soap12();
NfeStatusServicoNF2Result r = s.nfeStatusServicoNF2(dadosMsgE, new Holder<NfeCabecMsg>(cabecMsg));
esse é o SOAP que ele gera para enviar.
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Header>
<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:ns2="http://www.portalfiscal.inf.br/nfe">
<cUF>35</cUF>
<versaoDados>2.00</versaoDados>
</nfeCabecMsg>
</S:Header>
<S:Body>
<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:ns2="http://www.portalfiscal.inf.br/nfe">
<ns2:consStatServ versao="2.00">
<ns2:tpAmb>2</ns2:tpAmb>
<ns2:cUF>35</ns2:cUF>
<ns2:xServ>STATUS</ns2:xServ>
</ns2:consStatServ>
</nfeDadosMsg>
</S:Body>
</S:Envelope>
SOAP de resposta.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
<cUF>35</cUF>
<versaoDados>2.00</versaoDados>
</nfeCabecMsg>
</soap:Header>
<soap:Body>
<nfeStatusServicoNF2Result xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
<retConsStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
<tpAmb>2</tpAmb>
<verAplic>SP_NFE_PL_006h</verAplic>
<cStat>404</cStat>
<xMotivo>Rejeição: Uso de prefixo de namespace não permitido</xMotivo>
<cUF>35</cUF>
<dhRecbto>2010-11-04T23:12:56</dhRecbto>
</retConsStatServ>
</nfeStatusServicoNF2Result>
</soap:Body>
</soap:Envelope>
sim eu sei que o que esta errado é ter dois namespace na mesma TAG, mas ai é que esta minha pergunta
como configuro o JAXB ou o JAX-WS para ele passar o namespace xmlns:ns2=“http://www.portalfiscal.inf.br/nfe” para
a tag consStatServ, pois pelo que andei vendo pelo forum é a única diferença que encontrei com o xml do pessoal que conseguiu.
PS.: Codigos extras que utilizei
NfeCabecMsg
[code]package br.inf.portalfiscal.nfe.wsdl.nfestatusservico2;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
/**
-
Java class for nfeCabecMsg complex type.
-
-
The following schema fragment specifies the expected content contained within this class.
-
-
- <complexType name=“nfeCabecMsg”>
- <complexContent>
-
<restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-
<sequence>
-
<element name="cUF" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-
<element name="versaoDados" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-
</sequence>
-
<anyAttribute/>
-
</restriction>
- </complexContent>
- </complexType>
-
-
-
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = “nfeCabecMsg”, propOrder = {
“cuf”,
“versaoDados”
})
@XmlRootElement(name = “nfeCabecMsg”)
public class NfeCabecMsg {
@XmlElement(name = "cUF")
protected String cuf;
protected String versaoDados;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
// @XmlAttribute
// private String xmlnss = “http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2”;
/**
* Gets the value of the cuf property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCUF() {
return cuf;
}
/**
* Sets the value of the cuf property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCUF(String value) {
this.cuf = value;
}
/**
* Gets the value of the versaoDados property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVersaoDados() {
return versaoDados;
}
/**
* Sets the value of the versaoDados property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setVersaoDados(String value) {
this.versaoDados = value;
}
/**
* Gets a map that contains attributes that aren't bound to any typed property on this class.
*
* <p>
* the map is keyed by the name of the attribute and
* the value is the string value of the attribute.
*
* the map returned by this method is live, and you can add new attribute
* by updating the map directly. Because of this design, there's no setter.
*
*
* @return
* always non-null
*/
public Map<QName, String> getOtherAttributes() {
return otherAttributes;
}
}
[/code]
NfeDadosMsg:
package br.inf.portalfiscal.nfe.wsdl.nfestatusservico2;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <any/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"content"
})
@XmlRootElement(name = "nfeDadosMsg")
public class NfeDadosMsg {
@XmlMixed
@XmlAnyElement(lax = true)
protected List<Object> content;
// @XmlAttribute
// private String xmlnss = "http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2";
/**
* Gets the value of the content property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the content property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getContent().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Object }
* {@link String }
*
*
*/
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
}
TConsStatServ :
[code]//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2010.11.04 at 09:16:13 AM BRST
//
package br.inf.portalfiscal.nfe;
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;
/**
- Tipo Pedido de Consulta do Status do Servico
-
-
Java class for TConsStatServ complex type.
-
-
The following schema fragment specifies the expected content contained within this class.
-
-
- <complexType name=“TConsStatServ”>
- <complexContent>
-
<restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-
<sequence>
-
<element name="tpAmb" type="{http://www.portalfiscal.inf.br/nfe}TAmb"/>
-
<element name="cUF" type="{http://www.portalfiscal.inf.br/nfe}TCodUfIBGE"/>
-
<element name="xServ" type="{http://www.portalfiscal.inf.br/nfe}TServ"/>
-
</sequence>
-
<attribute name="versao" use="required" type="{http://www.portalfiscal.inf.br/nfe}TVerConsStatServ" />
-
</restriction>
- </complexContent>
- </complexType>
-
-
-
*/
@XmlRootElement(name = “consStatServ”)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = “TConsStatServ”, propOrder = {
“tpAmb”,
“cuf”,
“xServ”
})
public class TConsStatServ {
@XmlElement(required = true)
protected String tpAmb;
@XmlElement(name = "cUF", required = true)
protected String cuf;
@XmlElement(required = true)
protected String xServ;
@XmlAttribute(required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String versao;
// @XmlAttribute(required=true)
// protected String xmlnss = “http://www.portalfiscal.inf.br/nfe”;
/**
* Gets the value of the tpAmb property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTpAmb() {
return tpAmb;
}
/**
* Sets the value of the tpAmb property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTpAmb(String value) {
this.tpAmb = value;
}
/**
* Gets the value of the cuf property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCUF() {
return cuf;
}
/**
* Sets the value of the cuf property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCUF(String value) {
this.cuf = value;
}
/**
* Gets the value of the xServ property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getXServ() {
return xServ;
}
/**
* Sets the value of the xServ property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setXServ(String value) {
this.xServ = value;
}
/**
* Gets the value of the versao property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVersao() {
return versao;
}
/**
* Sets the value of the versao property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setVersao(String value) {
this.versao = value;
}
}
[/code]
e tem dois package-info.java
o do direito nfe:
[code]/**
- Servi�o destinado � consulta do status do servi�o prestado pelo Portal da Secretaria de Fazenda Estadual.
-
*/
@javax.xml.bind.annotation.XmlSchema(namespace = “http://www.portalfiscal.inf.br/nfe”, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package br.inf.portalfiscal.nfe;
[/code]
e do direito nfe.wsdl.nfestatusservico2:
/**
* Servi�o destinado � consulta do status do servi�o prestado pelo Portal da Secretaria de Fazenda Estadual.
*
*/
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package br.inf.portalfiscal.nfe.wsdl.nfestatusservico2;