Eu consegui pelo .NET
Como falei, usando o services do .NET não funcionou.
Tive que implementar minha própria chamada.
Ficou assim:
public string ConsultarSituacaoLoteRPS(string CNPJ, string IM, string Protocolo)
{
String NfseDados = String.Format(
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<ConsultarSituacaoLoteRpsEnvio xmlns=\"http://www.issnetonline.com.br/webserviceabrasf/vsd/servico_consultar_situacao_lote_rps_envio.xsd\">" +
"<Prestador>" +
"<tc:CpfCnpj xmlns:tc=\"http://www.issnetonline.com.br/webserviceabrasf/vsd/tipos_complexos.xsd\">" +
"<tc:Cnpj>{0}</tc:Cnpj>" +
"</tc:CpfCnpj>" +
"</Prestador>" +
"<Protocolo>{1}</Protocolo>" +
"</ConsultarSituacaoLoteRpsEnvio>", CNPJ, Protocolo);
String s = String.Format(
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
"<soap:Body>" +
"<ConsultaSituacaoLoteRPS xmlns =\"http://www.issnetonline.com.br/webservice/nfd\">" +
"<xml>{0}</xml>" +
"</ConsultaSituacaoLoteRPS>" +
"</soap:Body>" +
"</soap:Envelope>",
NfseDados);
File.WriteAllText(cFileName.Replace(".xml", ".soap.xml"), s);
return this.SendRequest(s, "http://www.issnetonline.com.br/webservice/nfd/ConsultaSituacaoLoteRPS");
}
public string SendRequest(string data, string action)
{
try
{
WebRequestHandler handler = new WebRequestHandler();
if (this.Certificado != null)
handler.ClientCertificates.Add(this.Certificado);
HttpClient client = new HttpClient(handler);
client.DefaultRequestHeaders.ExpectContinue = false;
client.DefaultRequestHeaders.Add("Accept", "*/*");
//client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/soap+xml"));
//client.DefaultRequestHeaders.Add("SOAPAction", action);
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.8806)");
client.DefaultRequestHeaders.TransferEncodingChunked = null;
StringContent queryString = new StringContent(data, Encoding.UTF8, "text/xml");
HttpResponseMessage response = client.PostAsync(new Uri(this.Url), queryString).Result;
String responseValue = string.Empty;
Stream responseStream = null;
if (response != null)
{
Task task = response.Content.ReadAsStreamAsync().ContinueWith(t =>
{
responseStream = t.Result;
});
task.Wait();
string encoding = String.Join(",", response.Content.Headers.ContentEncoding);
if (response.Content.Headers.ContentEncoding.Contains("gzip"))
responseStream = new GZipStream(responseStream, CompressionMode.Decompress);
else if (response.Content.Headers.ContentEncoding.Contains("deflate"))
responseStream = new DeflateStream(responseStream, CompressionMode.Decompress);
using (StreamReader streamReader = new StreamReader(responseStream))
{
responseValue = streamReader.ReadToEnd();
}
}
return responseValue;
}
catch (Exception ex)
{
throw ex;
}
}
Eu usei os seguintes imports:
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;