3
I am trying to consume the Event Identifiers Query Webservice. But I get this return from the Recipe:
<eSocial
xmlns="http://www.esocial.gov.br/schema/consulta/identificadores-eventos/retorno/v1_0_0">
<retornoConsultaIdentificadoresEvts>
<status>
<cdResposta>142</cdResposta>
<descResposta>Assinatura do evento inválida. Padrão de assinatura não reconhecido.</descResposta>
</status>
</retornoConsultaIdentificadoresEvts>
This is the xml that is sending:
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<ConsultarIdentificadoresEventosEmpregador
xmlns="http://www.esocial.gov.br/servicos/empregador/consulta/identificadores-eventos/v1_0_0"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<consultaEventosEmpregador>
<eSocial
xmlns="http://www.esocial.gov.br/schema/consulta/identificadores-eventos/empregador/v1_0_0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<consultaIdentificadoresEvts>
<ideEmpregador>
<tpInsc>1</tpInsc>
<nrInsc>00000000000100</nrInsc>
</ideEmpregador>
<consultaEvtsEmpregador>
<tpEvt>S-1250</tpEvt>
<perApur>2018-12</perApur>
</consultaEvtsEmpregador>
</consultaIdentificadoresEvts>
<Signature
xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<DigestValue>l6K5QTBqOn2R5OVwfyjAQn2tcY2KLt+/WwQleOZ+yCQ=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>[...]</SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate>[...]</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</eSocial>
</consultaEventosEmpregador>
</ConsultarIdentificadoresEventosEmpregador>
</s:Body>
This is the code, as it is only for testing the certificate is fixed:
public static void ConsultarIdentificadoresEventosEmpregador()
{
ServicoConsultarIdentificadoresEventosClient client = new ServicoConsultarIdentificadoresEventosClient();
eSocial esocial = new eSocial();
esocial.consultaIdentificadoresEvts = new eSocialConsultaIdentificadoresEvts();
esocial.consultaIdentificadoresEvts.ideEmpregador = new TIdeEmpregador();
esocial.consultaIdentificadoresEvts.ideEmpregador.tpInsc = 1;
esocial.consultaIdentificadoresEvts.ideEmpregador.nrInsc = "00000000000100";
esocial.consultaIdentificadoresEvts.consultaEvtsEmpregador = new TConsultaEventosEmpregador();
esocial.consultaIdentificadoresEvts.consultaEvtsEmpregador.perApur = "2018-12";
esocial.consultaIdentificadoresEvts.consultaEvtsEmpregador.tpEvt = "S-1250";
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
certificado = store.Certificates[7];
var xml = Serialize(esocial);
client.ClientCredentials.ClientCertificate.Certificate = certificado;
SignXmlDoc(xml, certificado);
var retorno = client.ConsultarIdentificadoresEventosEmpregador(xml.DocumentElement);
client.Close();
}
And the signature code, I’ve tried it in many ways, even now it’s identical to that answer: Esocial - Error signing XML.
I used tools like xsd.exe and svcutil.exe for code generation.
The signature error was corrected, I was able to use the query of event identifiers and the download of them both in restricted production and production
– João