/// <summary>
 /// Deserializes workflow markup into an TRetConsStatServ object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output TRetConsStatServ object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out TRetConsStatServ obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(TRetConsStatServ);
     try
     {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
 public static bool LoadFromFile(string fileName, out TRetConsStatServ obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 public static bool LoadFromFile(string fileName, out TRetConsStatServ obj, out System.Exception exception)
 {
     return LoadFromFile(fileName, Encoding.UTF8, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an TRetConsStatServ object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output TRetConsStatServ object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out TRetConsStatServ obj, out System.Exception exception)
 {
     exception = null;
     obj = default(TRetConsStatServ);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out TRetConsStatServ obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an TRetConsStatServ object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output TRetConsStatServ object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out TRetConsStatServ obj, out System.Exception exception)
 {
     exception = null;
     obj = default(TRetConsStatServ);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Beispiel #7
0
        public TRetConsStatServ ConsultaStatusWs(TConsStatServ consStatServ, X509Certificate2 cert)
        {
            XmlNode strRetorno = null;
            TRetConsStatServ retornoStatus = new TRetConsStatServ();
            C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl);
            listaURL = WsUrls.BuscaURL(consStatServ.cUF, consStatServ.tpAmb);

            try
            {
                StatusServico2.NfeStatusServico2 wsMsg = default(StatusServico2.NfeStatusServico2);
                StatusServico2.nfeCabecMsg cab = new StatusServico2.nfeCabecMsg();

                //UF E VERSÃO DO CABEÇALHO
                cab.cUF = PegarCodigoUF(consStatServ.cUF);
                cab.versaoDados = consStatServ.versao;

                //CRIA UMA INSTANCIA DA CONEXÃO COM O WEBSERVICE
                wsMsg = new StatusServico2.NfeStatusServico2(listaURL.UrlNfeStatusServico);

                //ASSOCIA CABEÇALHO NFE
                wsMsg.nfeCabecMsgValue = cab;

                //DEFINE TEMPO MAXIMO DE ESPERA POR RETORNO
                wsMsg.Timeout = 100000;

                //ASSOCIA CERTIFICADO A CONEXAO WEBSERVICE
                wsMsg.ClientCertificates.Add(cert);

                //DEFINE PROTOCOLO USADO NA CONEXÃO
                //wsMsg.SoapVersion = SoapProtocolVersion.Soap12

                //CRIA UM NOVO DOCUMENTO XML                
                XmlDocument retornoXML = new XmlDocument();
                string nomeArquivoEnv = _PastaLog + System.DateTime.Now.ToString("yyyyMMddTHHmmss") + " -ped-sta.xml";
                string nomeArquivoRet = _PastaLog + System.DateTime.Now.ToString("yyyyMMddTHHmmss") + " -ret-sta.xml";

                XmlDocument dados = new XmlDocument();
                dados.LoadXml(Funcoes.RemoveNameSpaceFromXml(consStatServ.Serialize()));
                dados.Save(nomeArquivoEnv);

                //ENVIA CONSULTA PARA SEFAZ E OBTEM RETORNO EM FORMATO STRING
                strRetorno = wsMsg.nfeStatusServicoNF2(dados);
                retornoXML.LoadXml(strRetorno.OuterXml);
                retornoXML.Save(nomeArquivoRet);
                retornoStatus = TRetConsStatServ.LoadFromFile(nomeArquivoRet);

                return retornoStatus;

            }
            catch (Exception ex)
            {
                throw new System.InvalidOperationException("Erro ao consultar status do serviço. Erro: " + ex.Message);
            }
        }
 public static bool LoadFromFile(string fileName, out TRetConsStatServ obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
 public static bool LoadFromFile(string fileName, out TRetConsStatServ obj, out System.Exception exception)
 {
     return(LoadFromFile(fileName, Encoding.UTF8, out obj, out exception));
 }
 /// <summary>
 /// Deserializes xml markup from file into an TRetConsStatServ object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output TRetConsStatServ object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out TRetConsStatServ obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(TRetConsStatServ);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
 public static bool Deserialize(string xml, out TRetConsStatServ obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }