Simple way to communicate with SEFAZ SOAP web services
npm install sefaz-communicatorconstsefaz=require('sefaz-communicator')consturl='https://hnfe.sefaz.ba.gov.br/webservices/NFeStatusServico4/NFeStatusServico4.asmx'constmethodName='nfeStatusServicoNF'constmessage={$xml: `<consStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00"> <tpAmb>2</tpAmb> <cUF>29</cUF> <xServ>STATUS</xServ> </consStatServ>`,}constcertificate=Buffer.from('Pfx certificate in base64 string','base64')constpassword='password'constresponse=awaitsefaz.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)