Nfe - Nota Fiscal Eletronica

Prezados,

Primeria gostaria de falar que acompanho o forum a um bom tempo, e mesmo depois de procurar no forum e na internet não consegui resolver o meu problema.

Estou validando o meu xml de acordo com o xsd e aparece o seguinte erro:

Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 10 errors. Please call the 'setErrorHandler' method to fix this. Error: URI=file:/C:/Users/Administrator/Desktop/nfe/nf2.xml Line=2: Document is invalid: no grammar found. Error: URI=file:/C:/Users/Administrator/Desktop/nfe/nf2.xml Line=2: Document root element "NFe", must match DOCTYPE root "null". ERROR: cvc-elt.1: Cannot find the declaration of element 'NFe'.

Ja li no proprio forum que pode ser o meu xml , mas creio que não, vou postar o começo do mesmo

<?xml version="1.0" encoding="utf-8"?> <NFe xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe"> <infNFe versao="2.00" Id="NFe31101027673876000155552341478987451825228768">

Desde já Agradeço

Primeiro, o xml está errado sim, está mostrando que não está de acordo com o xsd, segundo você precisa apenas colocar um ErrorHandler para melhorar as mensagens de erro na validação.

Crie uma innerClass nessa classe que faz a validação:

[code]
// para guardar os erros no leiaute
public static String erroLeiaute = “”;

public boolean validarXML(String arquivoEsquema, String arquivoXML) throws ParserConfigurationException, SAXException, IOException {
boolean valido = false;

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

    factory.setNamespaceAware(true);
    factory.setValidating(true);
    factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
    factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", arquivoEsquema);
    DocumentBuilder builder = null;
    erroLeiaute = "";
    try {
        builder = factory.newDocumentBuilder();
        builder.setErrorHandler(new SchemasErrorHandler());
    } catch (ParserConfigurationException ex) {
    }

    org.w3c.dom.Document document;
    try {
        document = builder.parse(arquivoXML);
        org.w3c.dom.Node rootNode = document.getFirstChild();
    } catch (IOException ex) {
    } catch (SAXException ex) {
    }

    return true;
}

class SchemasErrorHandler implements ErrorHandler {

    public SchemasErrorHandler() {
    }

    public SchemasErrorHandler(String msg) {
    }

    public void error(SAXParseException ex) {
        erroLeiaute += "ERRO NORMAL: " + ex.getMessage() + "\n";
    }

    public void fatalError(SAXParseException ex) {
        erroLeiaute += "ERRO FATAL: " + ex.getMessage() + "\n";
    }

    public void warning(SAXParseException ex) {
        erroLeiaute += "AVISO: " + ex.getMessage() + "\n";
    }
}[/code]

[quote=javer]Primeiro, o xml está errado sim, está mostrando que não está de acordo com o xsd, segundo você precisa apenas colocar um ErrorHandler para melhorar as mensagens de erro na validação.
[/quote]

Caro javer, ja estava tratando o erro de maneira um pouco mais grosseira, mas estava.
Porém continuoc com o mesmo erro, e não consiguo identificar o erro no xml

Uso SAX para validador, muito bom, informa linha com erro, etc

o erro SAXParseException, há um método com o getLineNumber(), ajuda bastante

Boa tarde,

Estou implementando uma solução, via Web Service, para emissão de NF-e.

O problema é que a minha empresa atua em vários estados, sendo necessário emitir notas fiscais para diferentes estados.

As minhas dúvidas são:

  • É necessário baixar a Cadeia de Certificados de cada estado?
  • Em caso positivo, eu necessito gerar um .keystore para cada estado?

Obrigado
Fernando Hirata Alexandre

[quote=fhalexandre]Boa tarde,

Estou implementando uma solução, via Web Service, para emissão de NF-e.

O problema é que a minha empresa atua em vários estados, sendo necessário emitir notas fiscais para diferentes estados.

As minhas dúvidas são:

  • É necessário baixar a Cadeia de Certificados de cada estado?
  • Em caso positivo, eu necessito gerar um .keystore para cada estado?
    [/quote]

Eu uso um jks somente com todas as cadeias abaixo da ICP.
Caso queira, posso lhe ceder o meu cert.jks.
Informe um email para envio em pvt.

Alencar

Pessoal, alguém utiliza a consulta de cadastro da SEFAZ RS?
Para mim, a resposta vem como abaixo:

[quote]

RSb20100819100210
111
Consulta cadastro com uma ocorrencia
RS
999999999
2010-11-03T00:05:06
43

999999999
999999999
RS
1
NOME DO CLIENTE


[/quote]

Pelo manual 4.0.1-NT2009.006, teriam outras informações, mas parece serem opcionais…
Alguma dica a respeito? Alguma outra forma de consulta de cadastro completo?

Alencar

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>
  • &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    
  •   &lt;sequence>
    
  •     &lt;element name="cUF" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
    
  •     &lt;element name="versaoDados" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
    
  •   &lt;/sequence>
    
  •   &lt;anyAttribute/>
    
  • &lt;/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>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;any/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/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>
  • &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    
  •   &lt;sequence>
    
  •     &lt;element name="tpAmb" type="{http://www.portalfiscal.inf.br/nfe}TAmb"/>
    
  •     &lt;element name="cUF" type="{http://www.portalfiscal.inf.br/nfe}TCodUfIBGE"/>
    
  •     &lt;element name="xServ" type="{http://www.portalfiscal.inf.br/nfe}TServ"/>
    
  •   &lt;/sequence>
    
  •   &lt;attribute name="versao" use="required" type="{http://www.portalfiscal.inf.br/nfe}TVerConsStatServ" />
    
  • &lt;/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&#65533;o destinado &#65533; consulta do status do servi&#65533;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;

RA problema resolvido

TENTANDO___________________________________________
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
    <S:Header>
        <nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
            <cUF>35</cUF>
            <versaoDados>2.00</versaoDados>
        </nfeCabecMsg>
    </S:Header>
    <S:Body>
        <nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
            <consStatServ versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe">
                <tpAmb>2</tpAmb>
                <cUF>35</cUF>
                <xServ>STATUS</xServ>
            </consStatServ>
        </nfeDadosMsg>
    </S:Body>
</S:Envelope>___________________________________________________
RETORNANDO__________________________________________
<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>107</cStat>
                <xMotivo>Serviço em Operação</xMotivo>
                <cUF>35</cUF>
                <dhRecbto>2010-11-05T09:46:57</dhRecbto>
                <tMed>1</tMed>
            </retConsStatServ>
        </nfeStatusServicoNF2Result>
    </soap:Body>
</soap:Envelope>___________________________________________________
Serviço em Operação

rafaek, como vc resolveu esse problema do JAXB?

fiz um Handler, mais ou menos assim

package teste;

import java.util.Set;

import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class LogHandler implements SOAPHandler<SOAPMessageContext> {

// Initialize OtputStream (System.out) etc. ...
    public boolean handleMessage(SOAPMessageContext c) {
        SOAPMessage msg = c.getMessage();

        boolean request = ((Boolean) c.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)).booleanValue();

        try {
            
            if (request) { // This is a request message.
                // Write the message to the output stream
                Element n1 = (Element)msg.getSOAPHeader().getElementsByTagName("nfeCabecMsg").item(0);
                n1.removeAttribute("xmlns:ns2");
                Element n = (Element)msg.getSOAPBody().getElementsByTagName("nfeDadosMsg").item(0);
                n.removeAttribute("xmlns:ns2");
                if ( ((Element)msg.getSOAPBody()).getElementsByTagName("consultaCadastro2").getLength() > 0) {
                    Element n3 = (Element)msg.getSOAPBody().getElementsByTagName("consultaCadastro2").item(0);
                    n3.removeAttribute("xmlns:ns2");
                    n = n3;
                }



                NodeList nl = n.getElementsByTagName("*");

                for(int i = 0; i < nl.getLength(); i++) {
                    ((Element)nl.item(i)).setPrefix("");
                }

                System.out.println("TENTANDO___________________________________________");
                msg.writeTo(System.out);
            } else { // This is the response message
                System.out.println("RETORNANDO__________________________________________");
                msg.writeTo(System.out);
            }
            System.out.println("___________________________________________________");
        } catch (Exception e) {
        }
        return true;
    }

    public boolean handleFault(SOAPMessageContext c) {
        SOAPMessage msg = c.getMessage();
        try {
            System.out.println("ERRO___________________________________________");
            msg.writeTo(System.out);
            System.out.println("___________________________________________________");
        } catch (Exception e) {
        }
        return true;
    }

    public void close(MessageContext c) {
    }

    public Set getHeaders() {
        // Not required for logging
        return null;
    }
}

e depois antes de vc usar o webservice vc tem registrar ele, assim:

BindingProvider bp = (BindingProvider) s;
            //bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "");
            Binding binding = bp.getBinding();

            List handlerList = binding.getHandlerChain();
            if (handlerList == null) {
                handlerList = new ArrayList();
            }
            LogHandler loggingHandler = new LogHandler();
            handlerList.add(loggingHandler);
            binding.setHandlerChain(handlerList);

onde variavel s é o seu port

isso ta um lixo eu sei, mas é so para teste

amigo…
tem como vc dar mais algumas dicas de como usar varios certificados num mesmo sistema?
achei pouca coisa sobre SSLClientAxisEngineConfig, talves eu não esteja procurando certo…
achei este link http://wiki.apache.org/ws/FrontPage/Axis/DynamicSSLConfig mas não tive muito sucesso ainda…

abraco

[quote=alves.Felipe][quote=rafaelbtz]

  • Nosso sistema é WEB e trabalha com um grupo de empresas logo precisamos configuar o certificado do cliente de forma dinamica não da pra usar o System.properies.
    na versão 1 do XML eu utilizava uma classe chamada: org.apache.axis.client.SSLClientAxisEngineConfig

mais ou menos assim:

axisConfig.setKeyStoreType("PKCS12");
		axisConfig.setKeyStore("****");
		axisConfig.setKeyStorePassword("***");

[/quote]
amigo…
tem como vc dar mais algumas dicas de como usar varios certificados num mesmo sistema?
achei pouca coisa sobre SSLClientAxisEngineConfig, talves eu não esteja procurando certo…
achei este link http://wiki.apache.org/ws/FrontPage/Axis/DynamicSSLConfig mas não tive muito sucesso ainda…

abraco[/quote]

Para NFe da versão 1 é fácil basta usar a classe SSLClientAxisEngineConfig, que é mais ou menos o código desse link q vc passou

Mas para versão 2.0 utilizando Axis2 essa classe não funciona e eu ainda não resolvi plenamente o problema.
Assim que eu resolver eu posto aqui.
Na pior das hipoteses eu vou trocar o System.properties por uma classe minha que obtenha os valores da Session (ou seja Gambiarra)
Também andei testando criar uma Factory de SSLContext e setar na classe Stub essa factory na propriedade HTTPConstants.CUSTOM_PROTOCOL_HANDLER e tambem parece ter funcionado mas ainda não terminei os testes, estou em outro projeto agora vou voltar para a NFe semana que vem.

Valeu

só mais uma pergunta …
vc teve que criar toda a parte de Locator…stub, etc na mão?
ou vc adaptou as classes geradas pelo Axis1 para usar o SSLClientAxisEngineConfig?
tipo… naquele link que eu passei mostra para criar suas próprias classes…

URL soapURL = new URL("https://myserver.com/myapp/services/mywebserviceport"); 15 MyWebServiceServiceLocator locator = new MyServiceLocator(axisConfig); 16 MyWebServicePort port = locator.getMyWebServicePort(soapURL); 17 MyWebServiceBindingStub stub = (MyWebServiceBindingStub) port; 18 // make a call to the webservice (assume no params for this operation) 19 MyResultType result = stub.myoperation1();

[quote=alves.Felipe]só mais uma pergunta …
vc teve que criar toda a parte de Locator…stub, etc na mão?
ou vc adaptou as classes geradas pelo Axis1 para usar o SSLClientAxisEngineConfig?
tipo… naquele link que eu passei mostra para criar suas próprias classes…

URL soapURL = new URL("https://myserver.com/myapp/services/mywebserviceport"); 15 MyWebServiceServiceLocator locator = new MyServiceLocator(axisConfig); 16 MyWebServicePort port = locator.getMyWebServicePort(soapURL); 17 MyWebServiceBindingStub stub = (MyWebServiceBindingStub) port; 18 // make a call to the webservice (assume no params for this operation) 19 MyResultType result = stub.myoperation1(); [/quote]

Eu criei as classes através da ferramenta de geração do Eclipse a partir dos arquivos WSDL.

depois eu faço:

SSLClientAxisEngineConfig axisConfig = new SSLClientAxisEngineConfig();
axisConfig.setKeyStoreType(...
axisConfig.setKeyStore(...
...

e

new NfeRetRecepcaoLocator(axisConfig).getNfeRetRecepcaoSoap().nfeRetRecepcao(...

Mas não consegui fazer isso com o Axis 2 da NFe 2.0 se alguem conseguiu por favor me diga como é.

cara só para confirmar… sua aplicação roda em cima do Tomcat?
é uma aplicação Web?

[quote=alves.Felipe]cara só para confirmar… sua aplicação roda em cima do Tomcat?
é uma aplicação Web?[/quote]

é WEB roda no Glassfish 3

[quote=rafaelbtz][quote=alves.Felipe]só mais uma pergunta …
vc teve que criar toda a parte de Locator…stub, etc na mão?
ou vc adaptou as classes geradas pelo Axis1 para usar o SSLClientAxisEngineConfig?
tipo… naquele link que eu passei mostra para criar suas próprias classes…

URL soapURL = new URL("https://myserver.com/myapp/services/mywebserviceport"); 15 MyWebServiceServiceLocator locator = new MyServiceLocator(axisConfig); 16 MyWebServicePort port = locator.getMyWebServicePort(soapURL); 17 MyWebServiceBindingStub stub = (MyWebServiceBindingStub) port; 18 // make a call to the webservice (assume no params for this operation) 19 MyResultType result = stub.myoperation1(); [/quote]

Eu criei as classes através da ferramenta de geração do Eclipse a partir dos arquivos WSDL.

depois eu faço:

SSLClientAxisEngineConfig axisConfig = new SSLClientAxisEngineConfig();
axisConfig.setKeyStoreType(...
axisConfig.setKeyStore(...
...

e

new NfeRetRecepcaoLocator(axisConfig).getNfeRetRecepcaoSoap().nfeRetRecepcao(...

Mas não consegui fazer isso com o Axis 2 da NFe 2.0 se alguem conseguiu por favor me diga como é.[/quote]

Usa o JAX-WS para os webservice e o JAXB para criar as entidades é mamão com açucar, hoje consegui enviar, vizualizar, cancelar, em fim todas as operações.

WebService 2.0 da receita de SP.

Se precisa de dicas, só pedir.

[quote=rafaek][quote=rafaelbtz][quote=alves.Felipe]só mais uma pergunta …
vc teve que criar toda a parte de Locator…stub, etc na mão?
ou vc adaptou as classes geradas pelo Axis1 para usar o SSLClientAxisEngineConfig?
tipo… naquele link que eu passei mostra para criar suas próprias classes…

URL soapURL = new URL("https://myserver.com/myapp/services/mywebserviceport"); 15 MyWebServiceServiceLocator locator = new MyServiceLocator(axisConfig); 16 MyWebServicePort port = locator.getMyWebServicePort(soapURL); 17 MyWebServiceBindingStub stub = (MyWebServiceBindingStub) port; 18 // make a call to the webservice (assume no params for this operation) 19 MyResultType result = stub.myoperation1(); [/quote]

Eu criei as classes através da ferramenta de geração do Eclipse a partir dos arquivos WSDL.

depois eu faço:

SSLClientAxisEngineConfig axisConfig = new SSLClientAxisEngineConfig();
axisConfig.setKeyStoreType(...
axisConfig.setKeyStore(...
...

e

new NfeRetRecepcaoLocator(axisConfig).getNfeRetRecepcaoSoap().nfeRetRecepcao(...

Mas não consegui fazer isso com o Axis 2 da NFe 2.0 se alguem conseguiu por favor me diga como é.[/quote]

Usa o JAX-WS para os webservice e o JAXB para criar as entidades é mamão com açucar, hoje consegui enviar, vizualizar, cancelar, em fim todas as operações.

WebService 2.0 da receita de SP.

Se precisa de dicas, só pedir.[/quote]

JAXB eu ja to usando… me passa o caminho para o JAX-WS pq eu estou usando Axis

Alguém poderia me ajudar.

Estou tentando chamar o retRecepcao, mas estou recebendo um erro de Versão de Dados do cabeçalho errada.

O XML de envio está assim:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 1.10 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 2 XXXXXXXXXXXXXXXXXX

Estou sempre recebendo este retorno:

<?xml version="1.0" encoding="UTF-8"?> 2 SP_NFE_PL_005e XXXXXXXXXXXXXXXXXX 239 Rejeição: Cabeçalho - Versão do arquivo XML não suportada 35

Se eu altero o campo versao da tag para qualquer outro valor, retorna o seguinte erro:

<?xml version="1.0" encoding="UTF-8"?> 2 SP_NFE_PL_005e 242 Rejeição: Cabeçalho - Falha no Schema XML 35

Estou acessando o site do homologação de SP (https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/nferetrecepcao.asmx)

Alguém pode me ajudar?

Obrigado,
Fernando Hirata Alexandre