Search code examples
node.jsweb-servicessoapnode-soap

Node.js: Create one global SOAP client or one client per request


I am using NodeJS and need to connect to a SOAP service. From research, it sounds like https://github.com/vpulim/node-soap is the best package for this, though the question I have is independent of the package.

When creating a SOAP client. Should I be creating one client per APPLICATION or one client per REQUEST?

For example, say I have an endpoint /api/someMethod that needs to access the SOAP endpoint, should I:

a) Create the global soap client upon starting up the server and giving each route access to it

OR

b) Create a new soap client everytime the endpoint is accessed

Thanks!


Solution

  • The answer is to create one global soap client because node-soap isn't really async and can cause performance problems.

    Full answer provided here: https://github.com/vpulim/node-soap/issues/653