Builds the SOAP 1.2 envelope the 4.00 webservices expect.
Each service takes its message inside nfeDadosMsg, whose namespace is the
service's own WSDL namespace — that is what routes the call on the .asmx
endpoint, so it is per service rather than global.
The message itself is passed through untouched. For SefazNfe.authorize/1
that matters: the ERP owns the XML and a signed document must reach SEFAZ byte
for byte, or the signature breaks (SEFAZ-04).
Summary
Functions
SOAPAction URI for service.
consReciNFe for NFeRetAutorizacao4.
consSitNFe for NFeConsultaProtocolo4.
distDFeInt for NFeDistribuicaoDFe.
envEvento for NFeRecepcaoEvento4, carrying one already signed event.
enviNFe for NFeAutorizacao4, carrying one already signed NF-e.
consStatServ for NFeStatusServico4.
A CPF is 11 digits; anything else is treated as a CNPJ.
tpAmb for an environment: 1 is production, 2 is homologation.
Wraps message for service.
Types
@type service() :: SefazNfe.Endpoints.service()
Functions
SOAPAction URI for service.
consReciNFe for NFeRetAutorizacao4.
consSitNFe for NFeConsultaProtocolo4.
@spec dist_dfe(String.t(), pos_integer(), 1 | 2, {atom(), String.t()}) :: binary()
distDFeInt for NFeDistribuicaoDFe.
The cursor is one of {:ult_nsu, nsu} to walk forward, {:nsu, nsu} for a
single document, or {:ch_nfe, key} to fetch one by access key.
envEvento for NFeRecepcaoEvento4, carrying one already signed event.
enviNFe for NFeAutorizacao4, carrying one already signed NF-e.
ind_sinc 1 asks SEFAZ to process the batch in the same call and answer with
the protocol; 0 answers a receipt that SefazNfe.authorization_result/1 then
consults. The MOC allows up to 50 documents per batch, and v1 sends one.
The signed document is embedded verbatim apart from its XML declaration, which is not allowed inside another document. Touching anything else would break the signature.
@spec status_service(pos_integer(), 1 | 2) :: binary()
consStatServ for NFeStatusServico4.
xServ is fixed at STATUS; it is the only operation the service defines.
A CPF is 11 digits; anything else is treated as a CNPJ.
@spec tp_amb(:production | :homologation) :: 1 | 2
tpAmb for an environment: 1 is production, 2 is homologation.
Wraps message for service.
The UF services take nfeDadosMsg directly in the body. NFeDistribuicaoDFe
nests it one level deeper, inside the operation element — sending it flat
makes the Ambiente Nacional answer a null reference from its own .NET stack
rather than a cStat.