Loopback Soap Connector does not fill model with service methods

I am having problems using a soap webservice using loopback-connector-soap. I followed instructions from github and here .

I can use the web service provided in the example, but when I replace it with my wsdl it doesn't work. There are no errors after connecting, but after creating the model, the call to any method that was detected by the web service fails with an error message

Function of the ModelConstructor object (data, parameters) {if (! (This instance of ModelConstructor)) {return new ModelConstructor (data, parameters); } if (ModelClass.settings.unresolved) {throw new Error ('Model' + ModelClass.modelName + 'undefined.'); } ModelBaseClass.apply (this is, arguments); } does not have a GetAgentBalance method

My code snippet is shown below

var api = {};    
var ds = loopback.createDataSource('soap', {
        connector: 'loopback-connector-soap',
        remotingEnabled: true,
        wsdl: 'https://jambopay.com/agencyservices?WSDL',// The url to WSDL
        wsdl_options: {
            rejectUnauthorized: false,
            strictSSL: false,
            requestCert: true,
        }
    });

    // Unfortunately, the methods from the connector are mixed in asynchronously
    // This is a hack to wait for the methods to be injected

ds.once('connected', function () {
    // Create the model     
    var service = ds.createModel('AgencyService', {});

    api.getBalance = function (callback) {
        //Displays the parsed WSDL 
        console.log(ds.connector);
        var timestamp = moment().format('YYYY-MM-DD HH:mm:ss');
        var pass = crypto.createHash('sha1').update(apiUsername + timestamp + apiKey).digest("hex");
        //GetAgentBalance is a method in the web service.
        service.GetAgentBalance({ username: apiUsername, timestamp: timestamp, pass: pass }, function (err, response) {
            var result = (!err && response.Balance) ? response.Balance : null;
            callback(err, result);
        });

    }
});

module.exports = api;

      

console.log(ds.connector)

displays the contents of the wsdl plus a flag parsed:true

indicating that it was successfully parsed. Please help me figure out why the model is not populated with web service methods, which prevents the web service from being used. Please note that this web service works fine in ASP.NET, Java as well as PHP, and I think some other languages ​​and frameworks do. I am stuck at this point and your help is much appreciated.

+3


source to share





All Articles