2017-06-01 73 views
0

下面是我試過的代碼:如何格式化參數JSON以獲得SOAP響應?

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請求看起來是這樣的:

soapUI request

如何設置格式ARGS JSON這樣才能得到預期的結果?

回答

1

你應該改變你的JSON中XML

在這裏,你可以做到這一點在線(檢查/檢驗/試驗)http://convertjson.com/json-to-xml.htm

和關閉當然有,不只是這一個NPM模塊:

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

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

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

我希望這有助於