sefaz-communicator
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

sefaz-communicator

Simple way to communicate with SEFAZ SOAP web services

Install

npm install sefaz-communicator

Usage

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,
})

API

communicate(url, method, message, options)

url

Type: string

Web service URL

methodName

Type: string

Name of Wsdl Method

message

Type: object

Examples

message: { $xml: '<?xml>...'}

or

message: { nfeDadosMsg: '<?xml>...'}

(optional) options.certificate

Type: Buffer

Pfx Certificate as Buffer

(optional) options.password

Type: string

Certificate password

(optional) options.headers

Type: string array

Headers in xml

Example

headers: ['<cteCabecMsg>...</cteCabecMsg>']

(optional) options.httpClient

Type: http.HttpClient

Custom node-soap HttpClient

(optional) options.escapeXML

Type: boolean

Escape XML message (default: false)

(optional) options.forceSoap12Headers

Type: boolean

Force Soap12 Headers (default: true)

(optional) options.contentType

Type: string

Communication content type (default: application/soap+xml)

(optional) options.proxy

Type: string

Proxy url to use in the communication

(optional) options.customFormatLocation

Type: Function

Function to format location that the method is called

(optional) options.rawResponse

Type: boolean

If true, returns raw XML response (default: false)

Package Sidebar

Install

npm i sefaz-communicator

Weekly Downloads

38

Version

1.4.1

License

MIT

Unpacked Size

8.63 kB

Total Files

5

Last publish

Collaborators

  • andreiox