HTTP POST for Invoice

1

Expensive, Good Afternoon. I need to send an XML via post to the webservice function of Nota Fiscal Paulistana. However, the XML is correct, it just returns a message that is very generic, so there is not much to say to you. I'd just like you to check if the call I'm making is correct, or if there's something wrong. Here is the code below.

public string RequestWebService(string wsURL, string param, string action, X509Certificate2 certificado)
        {
            Uri urlpost = new Uri(wsURL);
            HttpWebRequest httpPostConsultaNFe = (HttpWebRequest)HttpWebRequest.Create(urlpost);

            string postConsultaComParametros = param;
            byte[] buffer2 = Encoding.ASCII.GetBytes(postConsultaComParametros);

            httpPostConsultaNFe.CookieContainer = cookies;
            httpPostConsultaNFe.Timeout = 300000;
            httpPostConsultaNFe.ContentType = "text/xml; charset=utf-8; action=" + action;
            httpPostConsultaNFe.Method = "POST";
            httpPostConsultaNFe.ClientCertificates.Add(certificado);
            httpPostConsultaNFe.ContentLength = buffer2.Length;

            Stream PostData = httpPostConsultaNFe.GetRequestStream();
            PostData.Write(buffer2, 0, buffer2.Length);
            PostData.Close();

            HttpWebResponse responsePost = (HttpWebResponse)httpPostConsultaNFe.GetResponse();
            Stream istreamPost = responsePost.GetResponseStream();
            StreamReader strRespostaUrlConsultaNFe = new StreamReader(istreamPost, System.Text.Encoding.ASCII);

            return strRespostaUrlConsultaNFe.ReadToEnd();
        }

Can you help me, please?

Thank you.

    
asked by anonymous 03.02.2016 / 19:59

0 answers