Reinf - Event error R-5011

Asked

Viewed 987 times

1

While trying to sign the R-5011 consultation event, I am encountering this error:

"The element of thehttp://www.reinf.esocial.gov.br/schemas/evtTotalContrib/v1_03_00:nrProtEntr' is invalid - The value ? 4308-2099-1701-4308' is invalid depending on the data type String' - The current length is not equal to the specified length."

This is the xml of the event before signing:

<?xml version="1.0" encoding="UTF-8"?>
<Reinf xmlns="http://www.reinf.esocial.gov.br/schemas/evtTotalContrib/v1_03_00">
    <evtTotalContrib id="ID1102200480000002018041218075500001">
        <ideEvento>
            <perApur>2017-01</perApur>
        </ideEvento>
        <ideContri>
            <tpInsc>1</tpInsc>
            <nrInsc>10220048</nrInsc>
        </ideContri>
        <ideRecRetorno>
            <ideStatus>
                <cdRetorno>2</cdRetorno>
                <descRetorno>EM PROCESSAMENTO</descRetorno>
            </ideStatus>
        </ideRecRetorno>
        <infoRecEv>
            <nrProtEntr>4308-2099-1701-4308</nrProtEntr>
            <dhProcess>2018-04-12T18:07:55</dhProcess>
            <tpEv>2099</tpEv>
            <idEv>ID1102200480000002018040914443600001</idEv>
            <hash>Wh6iWTlvKY+tApuALf0IFC0+u86EulO4oUNjTF6R/mY=</hash>
        </infoRecEv>
        <infoTotalContrib>
            <nrRecArqBase>4308-05-2099-1701-4308</nrRecArqBase>
            <indExistInfo>3</indExistInfo>
        </infoTotalContrib>
    </evtTotalContrib>
</Reinf>

Could someone tell me how to fix this?

  • 1

    Is the error giving when signing XML, as you said in the question, or when sending the event to the EFD-Reinf Webservice? If it’s when you sign, put the code snippet you’re using to sign the event so we can figure out what it might be.

  • 1

    To post XML here in the OS, just paste the XML code, select it and click on the image {} (Code sample <pre> <code> Ctrl+K) in the edit bar above the text box where you write the question. And, for the OS to properly format XML, put the tag xml in your question (I have already edited and made these changes).

  • 1

    I understood the wrong situation, the 5011 event does not need - nor should it - to be signed, even because it will not be broadcast. Even so, this error occurs before the signature

  • 1

    Actually, in a hurry I didn’t even notice that detail either, because I’m more involved with eSocial than EFD-Reinf at the moment, but if it’s the same eSocial scheme, that event will probably be received only, it won’t be sent.

1 answer

1


After the messages we exchanged in the comments, I did a search here and saw that actually this event R-5011 ("Background information and consolidated taxes by calculation period", by name evtTotalContrib, defined in the file 'returnTotalizerContribuinte-v1_03_02.xsd') really is just a return event, ie you do not need to fill it out, sign it and send it, is the EFD-Reinf that will fill out, sign and return to you that event, in consultation.

It took me a while to understand the query (which they released a little while ago), because her scheme is a little different from eSocial, and the EFD-Reinf Sending Webservice itself.

I don’t know if you already know, and if you have written the routine to make the query, but, the address to access the EFD-Reinf query Webservice is this one:

Restricted Production Environment (test):
https://preprodefdreinf.receita.fazenda.gov.br/WsReinfConsultas/ConsultasReinf.svc

Environment of Production (official):
https://reinf.receita.fazenda.gov.br/WsReinfConsultas/ConsultasReinf.svc

And the WSDL address, to add a reference to the query service in your project, is this one:

Restricted Production Environment (test):
https://preprodefdreinf.receita.fazenda.gov.br/WsReinfConsultas/ConsultasReinf.svc?singleWsdl

Environment of Production (official):
https://reinf.receita.fazenda.gov.br/WsReinfConsultas/ConsultasReinf.svc?singleWsdl

But the WSDL of the query service can also be downloaded from this other address:

http://sped.rfb.gov.br/arquivo/show/2548

I noticed that the input parameters for the query service are already set to direct in the WSDL, not in a file. XSD part, as in the case of eSocial and EFD-Reinf shipping service:

<wsdl:types>
    <xs:schema elementFormDefault="qualified" targetNamespace="http://sped.fazenda.gov.br/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="ConsultaInformacoesConsolidadas">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="1" maxOccurs="1" name="tipoInscricaoContribuinte" type="xs:unsignedByte"/>
                    <xs:element minOccurs="0" maxOccurs="1" name="numeroInscricaoContribuinte" type="xs:string"/>
                    <xs:element minOccurs="0" maxOccurs="1" name="numeroProtocoloFechamento" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        [...]
    </xs:schema>
</wsdl:types>

So I created a test project, added the reference to the service (called the namespace of the added service Wsconsultas) and I checked that the consultation would look like this:

using System.ServiceModel;
using System.Xml.Linq;

// [...]

// Acessando o serviço no ambiente de Produção Restrita (teste).
var urlServicoConsulta =
  @"https://preprodefdreinf.receita.fazenda.gov.br/WsReinfConsultas/ConsultasReinf.svc";
var address = new EndpointAddress(urlServicoConsulta);
var binding = new BasicHttpsBinding();  //Disponível desde .NET Framework 4.5
// ou:
//var binding = new BasicHttpBinding(BasicHttpsSecurityMode.Transport);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

// Instancia o cliente para acessar o serviço de consulta do EFD-Reinf.
var wsClient = new WsConsultas.ConsultasReinfClient(binding, address);
wsClient.ClientCredentials.ClientCertificate.Certificate = x509Cert;

byte tipoInscricaoContribuinte = 1;
string numeroInscricaoContribuinte = "10220048";
string numeroProtocoloFechamento = "4308-2099-1701-4308";
// Solicita uma consulta, passando os parâmetros
// e recebendo o evento R-5011 como retorno.
XElement retornoTotalContrib = 
            wsClient.ConsultaInformacoesConsolidadas(
                 tipoInscricaoContribuinte, 
                 numeroInscricaoContribuinte,
                 numeroProtocoloFechamento);
wsClient.Close();

You can read a little more about this consultation service on Developer Guidance Manual v1.3, from page 43 to page 53:

http://sped.rfb.gov.br/arquivo/download/2523

Browser other questions tagged

You are not signed in. Login or sign up in order to post.