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)– Pedro Gaspar
@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.– Francisco Luz
@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.– Francisco Luz
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 elementReinf
was amended byv1_04_00
(correct) forv1_03_02
(wrong). In the second elementReinf
it would be interesting to delete the attributesxmlns:xsd
andxmlns:xsi
. In the elementevtInfoContri
use in attributeid
the same value used in the elementevento
. In the elementtpAmb
use the value "2" (Restricted Production). The CNPJ-base informed in the elementnrInsc
must be the same used in the attributeid
of the elementsevtInfoContri
andevento
.– Pedro Gaspar
@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.– Francisco Luz
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.– Francisco Luz
@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?
– Francisco Luz
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
andDecrypt HTTPS traffic
and click the buttonExport Root Certificate to Desktop
to automatically import the root certificate.– Francisco Luz