Node.js 如何格式化args JSON以获得SOAP响应?

Node.js 如何格式化args JSON以获得SOAP响应?,node.js,soap,protractor,soapui,Node.js,Soap,Protractor,Soapui,下面是我尝试的代码: fetchUserDetails: function () { var url = 'http://ldniguiapp02.eur.ad.tullib.com/matchbox-forwarddeal/services/RefDataWebServices?wsdl'; var args = {'args0': { 'mnemonic':'ttan', 'postingId':'75655',

下面是我尝试的代码:

fetchUserDetails: function () {
    var url = 'http://ldniguiapp02.eur.ad.tullib.com/matchbox-forwarddeal/services/RefDataWebServices?wsdl';
    var args = {'args0':
        {
            'mnemonic':'ttan',
            'postingId':'75655',
            'customerId':'180816',
            'organisation':{
                'customerId':'180816',
                'firmName':'POLITICAL.GROUP'
            },
            'userType':'TRADER'
        }};
    var defered = q.defer();
    soap.createClient(url, CreateClient);
    function CreateClient(err, client) {
        client.getUserDetails(args, function (err, result) {
            if (err) {
                defered.reject(err);
            }else{
                defered.resolve(result);
            }
            console.log(result);
        });
    }
    return defered.promise;
}
来自SOAP UI的等效SOAP请求如下所示:


如何格式化args json以获得预期结果?

您应该将json转换为xml格式

在这里,您可以在线执行此操作(检查/验证/测试)

当然,还有一个npm模块可以做到这一点:

我希望这有帮助

...
var jsonxml = require('jsontoxml');

var xmlArgs = jsonxml(args);
...
client.getUserDetails(xmlArgs, function (err, result) {
...
})
...