Coder Social home page Coder Social logo

sefaz-communicator's Introduction

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)

sefaz-communicator's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sefaz-communicator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.