0
Someone can help me or has been through this trouble?
I am doing a project to integrate my software with the GNRE webservice to send the guides in an automated way.
In the integration with Webservice I am sending the SOAP package below, but I am with the following answer:
The remote server returned an error: (500) Internal Server Error
I was looking at some posts and I was told that it may also be blocking Firewal.
Detail, I already have the digital certificate of the company installed and configured.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
< soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
< soap:Header>
< gnreCabecMsg xmlns="http://www.gnre.pe.gov.br/webservice/GnreLoteRecepcao">
< versaoDados>1.00</versaoDados>
< /gnreCabecMsg>
< /soap:Header>
< soap:Body>
< gnreDadosMsg xmlns="http://www.gnre.pe.gov.br/webservice/GnreLoteRecepcao">
< TLote_GNRE xmlns="http://www.gnre.pe.gov.br">
< guias>
< TDadosGNRE>
< c01_UfFavorecida>PE</c01_UfFavorecida>
< c02_receita>100099</c02_receita>
< c26_produto>20</c26_produto>
< c27_tipoIdentificacaoEmitente>1</c27_tipoIdentificacaoEmitente>
< c03_idContribuinteEmitente><CNPJ>XXXXXX</CNPJ></c03_idContribuinteEmitente>
< c06_valorPrincipal>0.01</c06_valorPrincipal>
< c14_dataVencimento>2015-06-05</c14_dataVencimento>
< c15_convenio>49-Protocolo</c15_convenio>
< c16_razaoSocialEmitente>XXXXXX</c16_razaoSocialEmitente>
< c18_enderecoEmitente>XXXXXX</c18_enderecoEmitente>
< c19_municipioEmitente>50308</c19_municipioEmitente>
< c20_ufEnderecoEmitente>SP</c20_ufEnderecoEmitente>
< c21_cepEmitente>XXXXXX</c21_cepEmitente>
< c22_telefoneEmitente>XXXXXX</c22_telefoneEmitente>
< c34_tipoIdentificacaoDestinatario>1</c34_tipoIdentificacaoDestinatario>
< c35_idContribuinteDestinatario><CNPJ>XXXXXXXXXX</CNPJ></c35_idContribuinteDestinatario>
< c37_razaoSocialDestinatario>XXXXXXXXXXXXXXXXX</c37_razaoSocialDestinatario>
< c38_municipioDestinatario>00054</c38_municipioDestinatario>
< c33_dataPagamento>2015-06-05</c33_dataPagamento>
< c05_referencia><mes>06</mes><ano>2015</ano></c05_referencia>
< c39_camposExtras>
< campoExtra>
< codigo>9</codigo><tipo>T</tipo><valor>XXXXXXXXXXXXXXXXXXXXXXXX</valor>
< /campoExtra>
< /c39_camposExtras>
< /TDadosGNRE></guias></TLote_GNRE></gnreDadosMsg>
< /soap:Body>
< /soap:Envelope>
I am using the following C# code for web service integration:
public HttpWebRequest RequisicaoGNRELoteRecepcao()
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create (@"https://www.testegnre.pe.gov.br/gnreWS/services/GnreLoteRecepcao");
string file;
file = @"C:\erp\Certificado.cer";
X509Certificate cer = X509Certificate.CreateFromCertFile(file);
webRequest.ClientCertificates.Add(cer);
webRequest.Headers.Add(@"SOAP:Action");
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
return webRequest;
}
public string WebServiceGNREEnviarLote(string arquivo, string xml)
{
HttpWebRequest request = RequisicaoGNRELoteRecepcao();
XmlDocument soapEnvelopeXml = new XmlDocument();
System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
soapEnvelopeXml.LoadXml(xml);
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
string soapResult = rd.ReadToEnd();
return soapResult;
}
}
}
Error 500 is internal server error. It is some error of their code there.
– Leonel Sanches da Silva
Your tags have space (e.g.:
< TDadosGNRE>
)? The right thing wouldn’t be without space<TDadosGNRE>
? Post the c# code you use to send the Soap.– Guilherme Nascimento