Como se podrían descargar los XML desde el SAT ?
Publicado: Sab Nov 01, 2014 8:11 pm
Que tal colegas desarrolladores
Alguien podrá ayudarme a iniciar un desarrollo en C# que pueda descargar los XML en forma masiva del SAT
Esta es la pagina del sat para consultar los CFDI o los XML
https://cfdiau.sat.gob.mx/nidp/app/logi ... tial&sid=0
Lo que quiero hacer es mediante programación es
1. Logearse a la pagina
2. Seleccionar Consulta de XML Emitidos o Recibidos
3. Indicar el periodo
4. Descargar los XML
Se que usando la clase WebClient uno puede simular navegar entre paginas web
La verdad nunca he usado este tipo de clases de POST y RESPOND por lo que no tengo ni idea.
Les anexo los 2 métodos mas populares que hay en cualquier foro de la web para enviar y recibir datos ..... pero no me queda claro como usar estos para poder hacer la descarga
Si alguien pudiera darme un ejemplo mas concreto a lo que requiero me serviría de mucho
public static string HttpGet(string URI)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
// req.Proxy = new System.Net.WebProxy(ProxyString, true); //true means no proxy
System.Net.WebResponse resp = req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}
public static string HttpPost(string URI, string Parameters)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
//req.Proxy = new System.Net.WebProxy(ProxyString, true);
//Add these, as we're doing a POST
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
//We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length); //Push it out there
os.Close();
System.Net.WebResponse resp = req.GetResponse();
if (resp == null) return null;
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}
Saludos
Halcón Divino
Monterrey, N.L.
Alguien podrá ayudarme a iniciar un desarrollo en C# que pueda descargar los XML en forma masiva del SAT
Esta es la pagina del sat para consultar los CFDI o los XML
https://cfdiau.sat.gob.mx/nidp/app/logi ... tial&sid=0
Lo que quiero hacer es mediante programación es
1. Logearse a la pagina
2. Seleccionar Consulta de XML Emitidos o Recibidos
3. Indicar el periodo
4. Descargar los XML
Se que usando la clase WebClient uno puede simular navegar entre paginas web
La verdad nunca he usado este tipo de clases de POST y RESPOND por lo que no tengo ni idea.
Les anexo los 2 métodos mas populares que hay en cualquier foro de la web para enviar y recibir datos ..... pero no me queda claro como usar estos para poder hacer la descarga
Si alguien pudiera darme un ejemplo mas concreto a lo que requiero me serviría de mucho
public static string HttpGet(string URI)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
// req.Proxy = new System.Net.WebProxy(ProxyString, true); //true means no proxy
System.Net.WebResponse resp = req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}
public static string HttpPost(string URI, string Parameters)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
//req.Proxy = new System.Net.WebProxy(ProxyString, true);
//Add these, as we're doing a POST
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
//We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length); //Push it out there
os.Close();
System.Net.WebResponse resp = req.GetResponse();
if (resp == null) return null;
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}
Saludos
Halcón Divino
Monterrey, N.L.