Simple way to communicate with SEFAZ SOAP web services
npm install sefaz-communicator
const sefaz = require('sefaz-communicator')
const url = 'https://hnfe.sefaz.ba.gov.br/webservices/NFeStatusServico4/NFeStatusServico4.asmx'
const methodName = 'nfeStatusServicoNF'
const message = {
$xml: `<consStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
<tpAmb>2</tpAmb>
<cUF>29</cUF>
<xServ>STATUS</xServ>
</consStatServ>`,
}
const certificate = Buffer.from('Pfx certificate in base64 string', 'base64')
const password = 'password'
const response = await sefaz.communicate(url, methodName, message, {
certificate,
password,
})
Type: string
Web service URL
Type: string
Name of Wsdl Method
Type: object
Examples
message: { $xml: '<?xml>...'}
or
message: { nfeDadosMsg: '<?xml>...'}
Type: Buffer
Pfx Certificate as Buffer
Type: string
Certificate password
Type: string array
Headers in xml
Example
headers: ['
<cteCabecMsg>...</cteCabecMsg>
']
Type: http.HttpClient
Custom node-soap HttpClient
Type: boolean
Escape XML message (default: false)
Type: boolean
Force Soap12 Headers (default: true)
Type: string
Communication content type (default: application/soap+xml)
Type: string
Proxy url to use in the communication
Type: Function
Function to format location that the method is called
Type: boolean
If true, returns raw XML response (default: false)