1

I am using strong-soap to call SOAP APIs from NodeJs application. I am able to call soap methods using following code.

createClient() {
   return new Promise((resolve, reject) => {
       soap.createClient(WYH_URL, this.options, (err: Error, mClient: any) => {
           if (err) {
               reject(err)
           } else {
               this.client = mClient;
               resolve(mClient)
           }
       });
   })
}

bookService = (data) => {
    var requestArgs = { SJson: JSON.stringify(data) }
    return this.createClient().then(success => {
        var method = this.client['BookService'];
        return method(requestArgs)
    })
}

As this nodeJS app is for dialogflow webhook, soap API responses should be quicker but above approach creates SOAP client everytime a soap method is to be called, which is taking more time than expected. Is there any approach that would be useful here which can eliminate creating soap clients for every method call?

Altaf Shaikh
  • 729
  • 8
  • 19

1 Answers1

0

Create a top level client, and re-use it for every query.

Taylor Caldwell
  • 381
  • 2
  • 7