WEbReference https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc
Codigo C#
ConsultaCFDI.ConsultaCFDIServiceClient oConsulta = new ConsultaCFDIServiceClient();
ConsultaCFDI.Acuse oAcuse = new Acuse();
oAcuse=oConsulta.Consulta("?re=BEN9501023I0&rr=SARM8209281F1&tt=440.000000&id=EC609EC1-5F63-4333-A2B8-2EDC10B68075");
MessageBox.Show("Estatus " + oAcuse.CodigoEstatus + " Estado: " + oAcuse.Estado);
Si te interesa hacer algo mas, un desarrollo integración de CFDI o validador de facturas de proveedores -> josmisu_@hotmail.com
Un poco de C#,JScript,VB, y CRM, Drupal, SQL , MSDCRM y MSDSL VBTools, developer, project lider, Social Media Activist, BlackBerry developer, telerik tools. (MCITP)
jueves, 6 de febrero de 2014
Validar UUID del SAT
Etiquetas:
CFDI,
https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc,
SAT,
UUID,
VALIDA CFD,
VALIDA CFDI,
VALIDA FACTURA,
VALIDA SAT
miércoles, 5 de febrero de 2014
Cómo leer Archivo de LCO del SAT
Function FileToString(ByVal filePath As String) As String
Dim f As FileStream
f = New FileStream(filePath, FileMode.Open, FileAccess.Read)
Dim streamLength As Integer = Convert.ToInt32(f.Length)
Dim fileData As Byte() = New Byte(streamLength) {}
f.Read(fileData, 0, streamLength)
f.Close()
Return System.Text.Encoding.Default.GetString(fileData)
End Function
Private Function LimpiaLCO(ByVal sPath As String, ByVal sFile As String) As String
Dim RutaLCO As [String] = sPath
Dim xmlLCO As String = RutaLCO & sFile
'Dim objReader As New StreamReader(xmlLCO)
Dim sRes As String = FileToString(xmlLCO) 'objReader.ReadToEnd()
Dim posIni As Integer = sRes.LastIndexOf("<?xml", System.StringComparison.Ordinal)
Dim posFin As Integer = sRes.LastIndexOf("</lco:LCO>", System.StringComparison.Ordinal)
sRes = sRes.Substring(posIni, posFin)
posFin = sRes.LastIndexOf("</lco:LCO>", System.StringComparison.Ordinal)
sRes = sRes.Substring(0, posFin)
Dim SW As StreamWriter
Dim origName = xmlLCO.Remove(xmlLCO.Length - 4)
origName += "Clean.XML"
SW = File.CreateText(sPath)
SW.WriteLine(sRes)
SW.WriteLine("</lco:LCO>")
SW.Close()
Return origName
End Function
Private Shared Sub LoadLco(ByVal sPathFileLCO_Clean As String)
'Dim RutaLCO As [String] = sPath
Dim xmlLCO As String = sPathFileLCO_Clean ' RutaLCO & sfileClean
'Cargamos XML
Dim xdoc As XDocument = XDocument.Load(xmlLCO)
'Query
Dim LCO = From Contribuyente In xdoc.Descendants("Contribuyente") _
Select New With {Key .RFC = Contribuyente.Attribute("RFC").Value, _
Key .Certificados = Contribuyente.Descendants("Certificado")}
'Resultado
For Each Contribuyente As Object In LCO
Console.WriteLine(Contribuyente.RFC)
For Each Certificado As Object In Contribuyente.Certificados
Dim Result = ""
Dim xAttribute = Certificado.Attribute("noCertificado")
If xAttribute IsNot Nothing Then
Result += " " & Convert.ToString(xAttribute.Value)
End If
Dim attribute = Certificado.Attribute("ValidezObligaciones")
If attribute IsNot Nothing Then
Result += " " & Convert.ToString(attribute.Value)
End If
Dim xAttribute1 = Certificado.Attribute("EstatusCertificado")
If xAttribute1 IsNot Nothing Then
Result += " " & Convert.ToString(xAttribute1.Value)
End If
Dim attribute1 = Certificado.Attribute("FechaInicio")
If attribute1 IsNot Nothing Then
Result += " " & Convert.ToString(attribute1.Value)
End If
Dim xAttribute2 = Certificado.Attribute("FechaFinal")
If xAttribute2 IsNot Nothing Then
Result += " " & Convert.ToString(xAttribute2.Value)
End If
MessageBox.Show(Result)
Next
Next
End Sub
Dim f As FileStream
f = New FileStream(filePath, FileMode.Open, FileAccess.Read)
Dim streamLength As Integer = Convert.ToInt32(f.Length)
Dim fileData As Byte() = New Byte(streamLength) {}
f.Read(fileData, 0, streamLength)
f.Close()
Return System.Text.Encoding.Default.GetString(fileData)
End Function
Private Function LimpiaLCO(ByVal sPath As String, ByVal sFile As String) As String
Dim RutaLCO As [String] = sPath
Dim xmlLCO As String = RutaLCO & sFile
'Dim objReader As New StreamReader(xmlLCO)
Dim sRes As String = FileToString(xmlLCO) 'objReader.ReadToEnd()
Dim posIni As Integer = sRes.LastIndexOf("<?xml", System.StringComparison.Ordinal)
Dim posFin As Integer = sRes.LastIndexOf("</lco:LCO>", System.StringComparison.Ordinal)
sRes = sRes.Substring(posIni, posFin)
posFin = sRes.LastIndexOf("</lco:LCO>", System.StringComparison.Ordinal)
sRes = sRes.Substring(0, posFin)
Dim SW As StreamWriter
Dim origName = xmlLCO.Remove(xmlLCO.Length - 4)
origName += "Clean.XML"
SW = File.CreateText(sPath)
SW.WriteLine(sRes)
SW.WriteLine("</lco:LCO>")
SW.Close()
Return origName
End Function
Private Shared Sub LoadLco(ByVal sPathFileLCO_Clean As String)
'Dim RutaLCO As [String] = sPath
Dim xmlLCO As String = sPathFileLCO_Clean ' RutaLCO & sfileClean
'Cargamos XML
Dim xdoc As XDocument = XDocument.Load(xmlLCO)
'Query
Dim LCO = From Contribuyente In xdoc.Descendants("Contribuyente") _
Select New With {Key .RFC = Contribuyente.Attribute("RFC").Value, _
Key .Certificados = Contribuyente.Descendants("Certificado")}
'Resultado
For Each Contribuyente As Object In LCO
Console.WriteLine(Contribuyente.RFC)
For Each Certificado As Object In Contribuyente.Certificados
Dim Result = ""
Dim xAttribute = Certificado.Attribute("noCertificado")
If xAttribute IsNot Nothing Then
Result += " " & Convert.ToString(xAttribute.Value)
End If
Dim attribute = Certificado.Attribute("ValidezObligaciones")
If attribute IsNot Nothing Then
Result += " " & Convert.ToString(attribute.Value)
End If
Dim xAttribute1 = Certificado.Attribute("EstatusCertificado")
If xAttribute1 IsNot Nothing Then
Result += " " & Convert.ToString(xAttribute1.Value)
End If
Dim attribute1 = Certificado.Attribute("FechaInicio")
If attribute1 IsNot Nothing Then
Result += " " & Convert.ToString(attribute1.Value)
End If
Dim xAttribute2 = Certificado.Attribute("FechaFinal")
If xAttribute2 IsNot Nothing Then
Result += " " & Convert.ToString(xAttribute2.Value)
End If
MessageBox.Show(Result)
Next
Next
End Sub
Suscribirse a:
Entradas (Atom)