Return Batch Events Reinf - The structure of the XML file is in disagreement with the XSD schema

Asked

Viewed 968 times

0

I am generating the R-1000 record for shipping test in the EFD-Reinf Restricted production environment and have already obtained assistance from the community in the following questions:

I can authenticate and consume the service successfully, but I get the following return XML:

<Reinf xmlns="http://www.reinf.esocial.gov.br/schemas/retornoLoteEventos/v1_04_00">
  <retornoLoteEventos id="ID68469C7A3421BB748AEC90BD323FDFA8">
    <ideTransmissor>
      <IdTransmissor>00000000000000</IdTransmissor>
    </ideTransmissor>
    <status>
      <cdStatus>0</cdStatus>
      <descRetorno>SUCESSO</descRetorno>
    </status>
    <retornoEventos>
      <evento id="ID1968278860001102019010910394300001">
        <Reinf xmlns="http://www.reinf.esocial.gov.br/schemas/evtTotal/v1_04_00">
          <evtTotal id="ID884299533">
            <ideEvento>
              <perApur />
            </ideEvento>
            <ideContri>
              <tpInsc>1</tpInsc>
              <nrInsc>0000000000000</nrInsc>
            </ideContri>
            <ideRecRetorno>
              <ideStatus>
                <cdRetorno>1</cdRetorno>
                <descRetorno>ERRO</descRetorno>
                <regOcorrs>
                  <tpOcorr>1</tpOcorr>
                  <localErroAviso />
                  <codResp>MS0030</codResp>
                  <dscResp>A estrutura do arquivo XML esta em desconformidade com o esquema XSD. The 'http://www.reinf.esocial.gov.br/schemas/evtInfoContribuinte/v1_04_00:classTrib' element is invalid - The value '1' is invalid according to its datatype 'String' - The actual length is not equal to the specified length.</dscResp>
                </regOcorrs>
              </ideStatus>
            </ideRecRetorno>
            <infoRecEv>
              <dhProcess>2019-01-09T11:40:20.8435498-02:00</dhProcess>
              <tpEv>1000</tpEv>
              <idEv>ID1968278860001102019010910394300001</idEv>
              <hash>BkxpXCyuN0HOZVaqxC4QA81P5LtK0XUd8ZsXs1B5c+w=</hash>
            </infoRecEv>
            <infoTotal />
          </evtTotal>
          <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="#ID884299533">
                <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>qQay/FoAyhWXgd1Xesk/2IM3kPo+nIZzbYiB9oW/OB0=</DigestValue>
              </Reference>
            </SignedInfo>
            <SignatureValue>[...]</SignatureValue>
            <KeyInfo>
              <X509Data>
                <X509Certificate>[...]</X509Certificate>
              </X509Data>
            </KeyInfo>
          </Signature>
        </Reinf>
      </evento>
    </retornoEventos>
  </retornoLoteEventos>
</Reinf>

XML Upload:

<Reinf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.reinf.esocial.gov.br/schemas/envioLoteEventos/v1_04_00">
  <loteEventos>
    <evento id="ID1968278860001102019011809000800001">
      <Reinf xmlns="http://www.reinf.esocial.gov.br/schemas/evtInfoContribuinte/v1_04_00">
        <evtInfoContri id="ID1968278860001102019011809000800001">
          <ideEvento>
            <tpAmb>2</tpAmb>
            <procEmi>1</procEmi>
            <verProc>1.00</verProc>
          </ideEvento>
          <ideContri>
            <tpInsc>1</tpInsc>
            <nrInsc>00000000000000</nrInsc>
          </ideContri>
          <infoContri>
            <inclusao>
              <idePeriodo>
                <iniValid>2019-01</iniValid>
              </idePeriodo>
              <infoCadastro>
                <classTrib>1</classTrib>
                <indEscrituracao>0</indEscrituracao>
                <indDesoneracao>0</indDesoneracao>
                <indAcordoIsenMulta>0</indAcordoIsenMulta>
                <contato>
                  <nmCtt>Nome Contato</nmCtt>
                  <cpfCtt>00000000000</cpfCtt>
                  <foneFixo>0000000000</foneFixo>
                </contato>
                <softHouse>
                  <cnpjSoftHouse>00000000000000</cnpjSoftHouse>
                  <nmRazao>RAZÃO SOCIAL</nmRazao>
                  <nmCont>Nome Responsável</nmCont>
                </softHouse>
              </infoCadastro>
            </inclusao>
          </infoContri>
        </evtInfoContri>
        <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="#ID1968278860001102019011809000800001">
              <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>8dVIB5s6fgiCxms/WmUZd/VZIw4tBNSeo4r+AqP7pPM=</DigestValue>
            </Reference>
          </SignedInfo>
          <SignatureValue>[...]</SignatureValue>
          <KeyInfo>
            <X509Data>
              <X509Certificate>[...]</X509Certificate>
            </X509Data>
          </KeyInfo>
        </Signature>
      </Reinf>
    </evento>
  </loteEventos>
</Reinf>

I am using the following C# code to send the request:

private XElement EnviarXML(XmlDocument xmlDocEventoEnvio, X509Certificate2 oX509Cert)
{
    XElement xmlResult = null;

    var urlServicoEnvio = @"https://preprodefdreinf.receita.fazenda.gov.br/wsreinf/RecepcaoLoteReinf.svc";
    var address = new EndpointAddress(urlServicoEnvio);
    var binding = new BasicHttpsBinding();

    // Informa que será usado um certificado digital para acessar o serviço.
    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

    RecepcaoLoteReinfClient recepcaoLoteReinfClient = new RecepcaoLoteReinfClient(binding, address);
    recepcaoLoteReinfClient.ClientCredentials.ClientCertificate.Certificate = oX509Cert;
    recepcaoLoteReinfClient.Open();
    xmlResult = recepcaoLoteReinfClient.ReceberLoteEventos((XElement.Parse(xmlDocEventoEnvio.OuterXml)));

    var retornoEnvio = XMLConverte.DeserializeFromXNode<RetornoLoteEventos.Reinf>(xmlResult);
    var eventos = retornoEnvio?.retornoLoteEventos.retornoEventos?.evento;

    foreach (var retornoEvtXml in eventos)
    {
        var retornoEvt = XMLConverte.DeserializeFromXmlNode<RetornoTotalizadorEvento.Reinf>(retornoEvtXml.Any);
        if (retornoEvt.evtTotal.ideRecRetorno.ideStatus.cdRetorno != 0)
            continue;
        var nrRecibo = retornoEvt.evtTotal.infoTotal?.nrRecArqBase;
        var hash = retornoEvt.evtTotal.infoRecEv.hash;
    }

    recepcaoLoteReinfClient.Close();

    return xmlResult;
}

Has anyone been there? I have not found similar questions here in the community.

1 answer

1


The error description gives the clue:

The structure of the XML file is in disagreement with the XSD scheme. The 'http://www.reinf.esocial.gov.br/schemas/evtInfoContribuinte/v1_04_00:classTrib' element is invalid - The value '1' is invalid According to its datatype 'String' - The actual length is not Equal to the specified length.

She says the value 1 that you reported in the field classTrib is invalid, and that the value length is different from the length specified by the XSD scheme.

Checking the layout of the R-1000 event in the documentation (v1.4), note that the field classTrib is of the character type with size 002, and there it says that it must be an existing code in the Table 8.

Checking the mentioned Table 8, note that the code is actually 01, then the right thing would be:

<classTrib>01</classTrib>
  • Peter, once again I thank you for helping me, it really was. Now I am facing error MS1010 - invalid ID, however I will still debug here to try to solve, if I fail to return to the community.

  • Maybe it’s the CNPJ part. In most employers the registration number identifying the employer is defined only by the root CNPJ, which are the first 8 digits of the number. When this happens, the ID should be informed as well, followed by zeroes, and it seems that you are not doing so.

Browser other questions tagged

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