EFD-Reinf via Postman -> Returns MS0028 error ("The loteEvents parameter was not reported in the service call")

Asked

Viewed 255 times

2

I am using the Postman to understand exactly what needs to be sent in http request.

Authentication:

In the program Postman I finished the menu Files -> Settings, flap Certificates and informed the file path . crt and . key.

On the field Host informed the value preprodefdreinf.receita.fazenda.gov.br

To create the . crt and . key files from the . pfx certificate I used the following commands:

$ openssl pkcs12 -in yourfile.pfx -nocerts -out keyfile-encrypted.key
$ openssl pkcs12 -in yourfile.pfx -clcerts -nokeys -out certificate.crt

Details of my request:

POST to https://preprodefdreinf.receita.fazenda.gov.br/WsREINF/RecepcaoLoteReinf.svc

Headers:

Content-Type: text/xml;charset=UTF-8
SOAPAction: http://sped.fazenda.gov.br/RecepcaoLoteReinf/ReceberLoteEventos

Body, select raw and XML(text/xml). Contents:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hs="http://www.holidaywebservice.com/HolidayService_v2/">
    <soapenv:Body>
        <Reinf xmlns="http://www.reinf.esocial.gov.br/schemas/envioLoteEventos/v1_04_00"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <loteEventos>
                <evento id="ID1236170070000002019090513234499999">
                    <Reinf>
                        <evtInfoContri id="ID1236170070000002019090513234499999">
                            <ideEvento>
                                <tpAmb>2</tpAmb>
                                <procEmi>1</procEmi>
                                <verProc>test</verProc>
                            </ideEvento>
                            <ideContri>
                                <tpInsc>1</tpInsc>
                                <nrInsc>23617007</nrInsc>
                            </ideContri>
                            <infoContri>
                                <inclusao>
                                    <idePeriodo>
                                        <iniValid>2019-01</iniValid>
                                    </idePeriodo>
                                    <infoCadastro>
                                        <classTrib>99</classTrib>
                                        <indEscrituracao>0</indEscrituracao>
                                        <indDesoneracao>0</indDesoneracao>
                                        <indAcordoIsenMulta>0</indAcordoIsenMulta>
                                        <indSitPJ>0</indSitPJ>
                                        <contato>
                                            <nmCtt>Some Idiot</nmCtt>
                                            <cpfCtt>53652495187</cpfCtt>
                                            <foneFixo>66535632196</foneFixo>
                                        </contato>
                                    </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="#ID1236170070000002019090513234499999">
                                     <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>...</DigestValue>
                                  </Reference>
                              </SignedInfo>
                              <SignatureValue>...</SignatureValue>
                              <KeyInfo>
                                  <X509Data>
                                      <X509Certificate>...</X509Certificate>
                                  </X509Data>
                              </KeyInfo>
                        </Signature>
                    </Reinf>
                </evento>
            </loteEventos>
        </Reinf>
    </soapenv:Body>
</soapenv:Envelope>

Server response:

MS0028 error - The loteEvents parameter was not reported in the service call

XML returned:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <ReceberLoteEventosResponse xmlns="http://sped.fazenda.gov.br/">
            <ReceberLoteEventosResult>
                <Reinf xmlns="http://www.reinf.esocial.gov.br/schemas/retornoLoteEventos/v1_04_00">
                    <retornoLoteEventos id="IDA4CAC6F4F4C5A6BFE294A3CBB090B5C2">
                        <ideTransmissor>
                            <IdTransmissor>00000000000000</IdTransmissor>
                        </ideTransmissor>
                        <status>
                            <cdStatus>1</cdStatus>
                            <descRetorno>ERRO</descRetorno>
                            <dadosRegistroOcorrenciaLote>
                                <ocorrencias>
                                    <tipo>1</tipo>
                                    <codigo>MS0028</codigo>
                                    <descricao>O parâmetro loteEventos não foi informado na chamada ao serviço.</descricao>
                                </ocorrencias>
                            </dadosRegistroOcorrenciaLote>
                        </status>
                    </retornoLoteEventos>
                    <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="#IDA4CAC6F4F4C5A6BFE294A3CBB090B5C2">
                                <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>...</DigestValue>
                            </Reference>
                        </SignedInfo>
                        <SignatureValue>...</SignatureValue>
                        <KeyInfo>
                            <X509Data>
                                <X509Certificate>...</X509Certificate>
                            </X509Data>
                        </KeyInfo>
                    </Signature>
                </Reinf>
            </ReceberLoteEventosResult>
        </ReceberLoteEventosResponse>
    </s:Body>
</s:Envelope>

Questions:

It looks like the server parser is NOT recognizing the tag <loteEventos> that I’m sending. It still seems to me that there’s something wrong between the beginning of XML and the tag <loteEventos>.

Can anyone see what’s wrong with the XML I’m sending?

Is there any way someone could use a traffic monitoring program, such as the Fiddler for example, capture the body of the body sent by any program capable of sending EFD-Reinf, create a gist on github and post the gist link in the comments? So I can compare your XML against mine.

To set up HTTPS interception in Fiddler:

Access https://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/DecryptHTTPS to see the documentation.

In the new version, access Settings instead of Tools. Then just select Capture HTTPS CONNECTs and click on Save Changes. The button Export Root Certificate to Desktop will become available, click on it to automatically import the root certificate. From this point on all traffic via port 443 (HTTPS) will be decrypted by Fiddler.

  • Francisco, in the configuration of the certificate in Postman you informed the value preprodefdreinf.receita.fazenda.gov.br in the field Host? (https://learning.getpostman.com/docs/postman/sending_api_requests/certificates) Can you place the full XML in the question? (hide only private information)

  • @Pedrogaspar Yes, the value of the Host field is preprodefdreinf.receita.fazenda.gov.br. I tested trying to send requests WITHOUT informing the certificate or reporting wrong data, the server returns permissions related error.

  • @Pedrogaspar I changed the question by adding the full XML that I use in Body. I added tb that it is necessary to select XML(text/xml). With this XML the server should return error related to the fact that XML is NOT signed.

  • And the element Signature which was previously present in the upload XML? It is no longer in this edition. I also noticed that the version indicated in the first element Reinf was amended by v1_04_00 (correct) for v1_03_02 (wrong). In the second element Reinf it would be interesting to delete the attributes xmlns:xsd and xmlns:xsi. In the element evtInfoContri use in attribute id the same value used in the element evento. In the element tpAmb use the value "2" (Restricted Production). The CNPJ-base informed in the element nrInsc must be the same used in the attribute id of the elements evtInfoContri and evento.

  • @Pedrogaspar Thank you very much for your time. I changed the XML of the question. Now the request XML reflects all your suggestions. The server keeps returning the same error. It seems to me that the tag <Signature>, at this point, it is irrelevant because the error accuses that something went wrong before reaching the xml of the event being sent. The moment all goes well and the server parser reaches the signature tag, it would then return some signature-related error.

  • The server parser is NOT recognizing the tag <loteEventos> I am sending. It seems to me that there is something wrong between the tag <loteEventos> and the beginning of xml.

  • @Pedrogaspar would like you, please use some program that monitors traffic, such as Fiddler if you use Windows, and capture the body of the body sent by any program that is able to deliver EFD Reinf?

  • Go to https://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/DecryptHTTPS to see how to intercept traffic at port 443 ( HTTPS ). It’s very simple, just select Capture HTTPS CONNECTs and Decrypt HTTPS traffic and click the button Export Root Certificate to Desktop to automatically import the root certificate.

Show 3 more comments

1 answer

1


The problem is in the envelope formatting, the root element was missing (in SOAP’s Body) ReceberLoteEventos encapsulating the EFD-Reinf lot.

The constant envelope example in developer’s manual, version 1.4.01, page 16, is wrong and incomplete.

Follows the correct envelope model:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sped="http://sped.fazenda.gov.br/">
    <soapenv:Header />
    <soapenv:Body>
        <sped:ReceberLoteEventos>
            <sped:loteEventos>
                <Reinf xmlns="http://www.reinf.esocial.gov.br/schemas/envioLoteEventos/v1_04_00">
                    <loteEventos>
                        <evento id="EVENTO_ID_AQUI">
                            <Reinf>
                                <!-- Resto do XML do evento aqui... -->
                            </Reinf>
                        </evento>
                    </loteEventos>
                </Reinf>
            </sped:loteEventos>
        </sped:ReceberLoteEventos>
    </soapenv:Body>
</soapenv:Envelope>
  • Francisco, how did it work? The root element was missing (in Body) ReceberLoteEventos, before the element loteEventos, isn’t it? I never see the SOAP envelope because I use . NET and the SOAP envelope is created automatically by the framework.

  • @Yes, this way it works. Before using any framework I wanted to first know and understand exactly what is sent.

  • Now that I understand that SOAP is nothing more than a simple POST with an extra header, now I was able to create a script with only 3 lines of code, using lib https://github.com/Kong/unirest-php, to send the Xmls.

  • PHP has a lib for SOAP, but it seems to me that it’s too complicated for something that’s essentially as simple as a web form.

  • How nice of Francis. I can not say if SOAP is limited to just this, I confess that I do not have much knowledge in this area, but nice that you have gone deeper into this and detailed in the post. You can mark your own answer as an answer, to help other people who have the same question in the future. I just don’t understand why you said in your reply that the example in the developer manual is incorrect.

  • @Pedrogaspar I include in the answer the link, the version and the page of the manual where the example of envelope I refer. The envelope of the manual DOES NOT work and so I consider it to be wrong and incomplete. Regarding SOAP, there is definitely a lot more. What I meant was that I think it’s important to understand the core of it. When it comes to the transmission of requests, SOAP is simpler than REST. SOAP only uses the POST method, while REST has PUT, DELETE, PATCH, among others.

  • Ah yes, but note that in this example of p. 16 the text before the example is "Example of a soap message", that is, it is a generic example of the structure of any SOAP message. The only example of a EFD-Reinf XML is the one on page 20, and yet it’s only to demonstrate the signature part.

  • I couldn’t find anywhere in the documentation and NOR in the XSD information that led to the conclusion that there is a need for tags <sped:ReceberLoteEventos> and <sped:loteEventos>. Not to mention that these technical manuals of governments are written by people with bureaucratic mentality and thus are poorly structured and, instead of clarifying and guiding, cause mental confusion in the reader.

Show 3 more comments

Browser other questions tagged

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