I'm using this npm package: https://www.npmjs.com/package/soap
I could not find an answer in the documentation, as I'm wondering if the best practice for SOAP client is to create a single client as startup and use for all requests (similar to database client), or create a new one per request.
A SOAP client and server for node. js. This module lets you connect to web services using SOAP. It also provides a server that allows you to run your own SOAP services.
strong-soap provides a mock-up SOAP server capability to implement and test a web service. Here is an example of creating a SOAP server and sending a JSON response: var soap = require('strong-soap').
SOAP is basically an XML based API that existed before the REST API existed. SOAP stands for Simple Object Access Protocol – it's a mostly legacy protocol that was designed for doing remote api requests in a language independent way.
It depends on your use case and application requirements.
After reading up on the code of the node-soap
, the following happens when createClient()
is called:
createClient(url, options, cb)
internally creates a wsdl handler for the particular url in question (wsdl.open_wsdl()
)url
as key (unless options.disableCache
is true
)createClient()
calls back with Client()
which wraps the wsdl handlerSo, unless your url
changes, it should be ok for you to use it as a singleton, since there's no need to run the setup code for wsdl yet again.
If your url
changes (or if you aren't sure if it changes), use createClient()
for each call. The wsdl setup will still be cached, so there's no overhead for you in this case (except for the first time the wsdl is created).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With