How to asynchronously service multiple QBWC clients with Node.js

淺唱寂寞╮ 提交于 2019-12-03 16:16:06
JohnB

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:

  1. Each method signature has an additional callback parameter
  2. There is no return, that's handled by callback() 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).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!