Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- web.Method = "POST";
- web.ContentType = "text/xml;charset=utf-8";
- web.Accept = "text/xml";
- web.Headers.Clear();
- web.Headers.Add("SOAPAction", url);
- X509Certificate2 certificado = ObterCertificado();
- if (certificado != null)
- {
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
- web.ClientCertificates.Add(certificado);
- }
- var soap = "<?xml version='1.0' encoding='UTF-8'?>";
- soap += "<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'>";
- soap += "<soap12:Body>";
- soap += " <cteDistDFeInteresse xmlns='http://www.portalfiscal.inf.br/cte/wsdl/CTeDistribuicaoDFe'>";
- soap += " <distDFeInt xmlns='http://www.portalfiscal.inf.br/cte' versao='1.00'>";
- soap += " <tpAmb>1</tpAmb>";
- soap += " <cUFAutor>91</cUFAutor>";
- soap += " <CNPJ>00000000000000</CNPJ>";
- soap += " <distNSU><ultNSU>000000000000000</ultNSU></distNSU>";
- soap += " </distDFeInt>";
- soap += " </cteDistDFeInteresse>";
- soap += "</soap12:Body>";
- soap += "</soap12:Envelope>";
- // soap = "<cteDadosMsg><distDFeInt xmlns='http://www.portalfiscal.inf.br/nfe' versao='1.00'><tpAmb>1</tpAmb><cUFAutor>35</cUFAutor><CNPJ>000000000000000</CNPJ><distNSU><ultNSU>000000000000002</ultNSU></distNSU></distDFeInt></cteDadosMsg>";
- var byteArray = Encoding.UTF8.GetBytes(soap);
- web.ContentLength = byteArray.Length;
- using (var stream = web.GetRequestStream())
- {
- stream.Write(byteArray, 0, byteArray.Length);
- }
- using (var webResponse = (HttpWebResponse)web.GetResponse())
- {
- using (var stream = webResponse.GetResponseStream())
- {
- retorno = new StreamReader(stream).ReadToEnd();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement