Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Mensajes - amcompe

Páginas: [1]
1
Hola este es mi intento, encuentro un error de protocolo favor si alguien me da una pista .
Por lo pronto  ya logre convertir la imagen a texto con una OCR en NET llamada tessnet2.dll.  Lo estoy mandando directo con datos fijos

private void mt_otro3()
        {
            try
            {
                //Creating the Web Request.
                HttpWebRequest httpWebRequest = HttpWebRequest.Create("http://www.sunat.gob.pe/cl-ti-itmrconsruc/jcrS00Alias") as HttpWebRequest;
                //Specifing the Method
                httpWebRequest.Method = "POST";
                //Data to Post to the Page, itis key value pairs; separated by "&"
                string data = "accion=consPorRuc&nroRuc=20100495989&search1:20100495989&codigo=FGRT&tipdoc=1";
                //Setting the content type, it is required, otherwise it will not work.
                httpWebRequest.ContentType = "application/x-www-form-urlencoded";
                //Getting the request stream and writing the post data
                using (StreamWriter sw = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    sw.Write(data);
                }
                //Getting the Respose and reading the result.
                HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse;
                using (StreamReader sr = new StreamReader(httpWebResponse.GetResponseStream()))
                {
                    MessageBox.Show(sr.ReadToEnd());
                }
            }
            catch (WebException wex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("ERROR:" + wex.Message + ". STATUS: " + wex.Status.ToString());

                if (wex.Status == WebExceptionStatus.ProtocolError)
                {
                    var response = ((HttpWebResponse)wex.Response);
                    sb.AppendLine(string.Format("Status Code : {0}", response.StatusCode));
                    sb.AppendLine(string.Format("Status Description : {0}", response.StatusDescription));

                    try
                    {
                        StreamReader reader = new StreamReader(response.GetResponseStream());
                        sb.AppendLine(reader.ReadToEnd());
                    }
                    catch (WebException ex) { throw; }
                }

                throw new Exception(sb.ToString(), wex);
            }

        }

Gracias.

2
sí dejo de funcionar a finales de diciembre del 2014, ahora que hacemos, por mi parte iré investigando, si tienen novedades comentenlo

Páginas: [1]