1

According to documentation on loopback, lb soap creates models of underlying soap based datasource. Is there a programmatic way to do this? I want to do it programmatically to facilitate a dynamic soap consumption through dynamically created models and datasources.

Technoshaft
  • 679
  • 6
  • 18

1 Answers1

1

Disclaimer: I am a co-author and maintainer of LoopBack.

Here is the source code implementing the command lb soap:

Here is the code that's generating models definition and method source code:

exports.generateAPICode = function generateAPICode(selectedDS, operationNames) { // eslint-disable-line max-len
  var apis = [];
  var apiData = {
    'datasource': selectedDS,
    'wsdl': selectedWsdl,
    'wsdlUrl': selectedWsdlUrl,
    'service': selectedService.$name,
    'binding': selectedBinding.$name,
    'operations': getSelectedOperations(selectedBinding, operationNames),
  };
  var code = soapGenerator.generateRemoteMethods(apiData);
  var models = soapGenerator.generateModels(apiData.wsdl, apiData.operations);
  var api = {
    code: code,
    models: models,
  };
  apis.push(api);
  return apis;
};

As you can see, most of the work is delegated to soapGenerator, which refers to loopback-soap - a lower-level module maintained by the LoopBack team too. In your application, you can use loopback-soap directly (no need to depend on our CLI tooling) and call its API to generate SOAP-related models.

Unfortunately we don't have much documentation for loopback-soap since it has been mostly an internal module so far. You will have to read the source code to build a better understanding. If you do so, then we would gladly accept contributions improving the documentation for future users.

Miroslav Bajtoš
  • 10,667
  • 1
  • 41
  • 99