Search code examples
node.jssoapsoapuisoap-clientnode-soap

node-soap: It not found the distribution method


Try using the node soap call a web service does not work, but if it works in 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);
  });
});

in SoapUI request would:

<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>

Thank you


Solution

  • 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