问题
The idea is to implement a QBWC web service using Node.js which can serve multiple incoming requests in an asynchronous fashion. Currently I am looking into qbws which is a Node.js web service for QuickBooks Desktop Web Connector. Any ideas on how I can extend this to support an asynchronous architecture for the service methods?
Thanks in Advance!
回答1:
The soap module supports asynchronous function calls which makes this easy to do. To use the same template as my other answer, here's how you'd do that:
var soap = require('soap');
var yourService = {
QBWebConnectorSvc: {
QBWebConnectorSvcSoap: {
serverVersion: function (args, callback) {
// serverVersion code here
callback({
serverVersionResult: { string: retVal }
});
},
clientVersion: function (args, callback) {
//clientVersion code here
callback({
clientVersionResult: { string: retVal }
});
},
// and all other service functions required by QBWC
}
}
};
There are two differences:
- Each method signature has an additional
callback
parameter - There is no
return
, that's handled bycallback()
instead.
I don't currently have a suitable environment to test this, but I created a client to imitate QuickBooks Web Connector and it worked fine. Converting the qbws methods to asynchronous allowed it to service multiple clients simultaneously (including one legitimate QBWC client).
来源:https://stackoverflow.com/questions/32870807/how-to-asynchronously-service-multiple-qbwc-clients-with-node-js