0

尝试使用节点soap调用Web服务不起作用,但如果它在SoapUI中起作用

var soap = require('soap');
var url = 'http://190.129.208.178:96/PasarelaServices/CustomerServices?wsdl';
var args = { "key": '12345', "parametros": 'parameters...' };
soap.createClient(url, function (err, client) {
  console.log(client.describe());
  console.log(client.describe().CustomerServices.CustomerServicesPort.solicitarPago);
  client.CustomerServices.CustomerServicesPort.solicitarPago(args, function (err, result, raw, soapHeader) {
    console.log(err);
    console.log(result)
    console.log(raw);
  });
});

在 SoapUI 请求中将:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.vlink.com.bo/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:solicitarPago>
         <key>12345</key>
         <parametros>parameters...</parametros>
      </ser:solicitarPago>
   </soapenv:Body>
</soapenv:Envelope>

谢谢

4

1 回答 1

0

Can solve it with:

var soap = require('soap');
var url = 'http://190.129.208.178:96/PasarelaServices/CustomerServices?wsdl';
var wsdlOptions = {
  "overrideRootElement": {
    "namespace": "ser",
    "xmlnsAttributes": [{ "name": "xmlns:ser", "value": "http://services.vlink.com.bo/" }]
  }
};
var args = { "key": '12345', "parametros": 'parameters...' };
soap.createClient(url, wsdlOptions, function (err, client) {
  client.solicitarPago(args, function (err, result, raw, soapHeader) {
    console.log(result);
  });
});

The problem was: it was necessary to establish the prefix "ser" with wsdlOptions

于 2016-11-08T15:40:44.900 回答