Npm soap包 - 编辑SOAP标头

时间:2015-12-14 11:29:43

标签: xml node.js soap meteor

我正在使用此包与某些服务器建立api连接。 API使用SOAP和XML技术构建。要在我的meteor.js应用程序中建立连接,我正在使用这个包

https://www.npmjs.com/package/soap

这就是我的代码的样子:

global.initSoapDexConnection = function() {
    Soap.createClient(
        Meteor.absoluteUrl('dss/DEXSingle.wsdl'),
        {
            endpoint: Meteor.settings.SOAP.DSS,
            forceSoap12Headers: true
        },
        function(err, client) {
            deleteFilesFromFolder(Meteor.settings.ApiInvestigator.path, true, ['DEX_procedures.txt','xml_newest.xml']);

            var security = new Soap.WSSecurity(
                'SOME LOGIN',
                'SOME PASSWORD',
                {
                    passwordType: 'PasswordText',
                    hasTimeStamp: true
                }
            );

            client.setSecurity(security);

            client.addListener('request', function(request) {
                console.log(request.constructor === String);
                initReportCreation(PrettyData.pd.xml(request), '.xml', 'listener_request');
            });

            client.Ping({}, function() {
                var responseForFile = '';
                for (var i = 0; i < arguments.length; i++) {
                    responseForFile += '<<<<<PARAMETER ' + i + '>>>>>\n\n';
                    responseForFile += JSON.stringify(arguments[i], null, 5);
                    responseForFile += '\n\n';
                }

                if (Meteor.settings.ApiInvestigator && Meteor.settings.ApiInvestigator.path) {
                    initReportCreation(responseForFile);
                } else {
                    console.log(responseForFile);
                }
            });

        }
    );
};

问题是,如何在请求之前编辑安全XML?假设我想为Password或Username XML标记添加新属性。

0 个答案:

没有答案