Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'strong-soap' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
// Copyright IBM Corp. 2013,2015. All Rights Reserved.
// Node module: loopback-connector-soap
// US Government Users Restricted Rights - Use, duplication or disclosure
// restricted by GSA ADP Schedule Contract with IBM Corp.
var g = require('strong-globalize')();
var soap = require('strong-soap').soap;
var debug = require('debug')('loopback:connector:soap');
var HttpClient = require('./http');
/**
* Export the initialize method to loopback-datasource-juggler
* @param {DataSource} dataSource The data source object
* @param callback
*/
exports.initialize = function initializeDataSource(dataSource, callback) {
var settings = dataSource.settings || {};
var connector = new SOAPConnector(settings);
dataSource.connector = connector;
dataSource.connector.dataSource = dataSource;
// Copyright IBM Corp. 2015. All Rights Reserved.
// Node module: loopback-connector-soap
// US Government Users Restricted Rights - Use, duplication or disclosure
// restricted by GSA ADP Schedule Contract with IBM Corp.
'use strict';
var req = require('request');
var util = require('util');
var url = require('url');
var debug = require('debug')('loopback:connector:soap:http');
var VERSION = require('../package.json').version;
var HttpClient = require('strong-soap').soap.HttpClient;
function LBHttpClient(options, connector) {
if (!(this instanceof LBHttpClient)) {
return new LBHttpClient(options, connector);
}
var httpClient = new HttpClient(this, options);
this.req = req;
if (options && options.requestOptions) {
this.req = req.defaults(options.requestOptions);
}
this.connector = connector;
}
util.inherits(LBHttpClient, HttpClient);
/**
// Copyright IBM Corp. 2017,2019. All Rights Reserved.
// Node module: generator-loopback
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var url = require('url');
var chalk = require('chalk');
var fs = require('fs');
var async = require('async');
var soapGenerator = require('loopback-soap');
var soap = require('strong-soap').soap;
var WSDL = soap.WSDL;
var path = require('path');
var selectedWsdl, selectedWsdlUrl, wsdlServices,
selectedService, selectedBinding;
// loads remote WSDL or local WSDL using strong-soap module APIs.
function loadWsdl(wsdlUrl, log, cb) {
WSDL.open(wsdlUrl, {}, function(err, wsdl) {
if (err) {
return cb(err);
}
cb(null, wsdl);
});
}
// Copyright IBM Corp. 2017,2019. All Rights Reserved.
// Node module: generator-loopback
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var url = require('url');
var chalk = require('chalk');
var fs = require('fs');
var async = require('async');
var soapGenerator = require('loopback-soap');
var soap = require('strong-soap').soap;
var WSDL = soap.WSDL;
var path = require('path');
var selectedWsdl, selectedWsdlUrl, wsdlServices,
selectedService, selectedBinding;
// loads remote WSDL or local WSDL using strong-soap module APIs.
function loadWsdl(wsdlUrl, log, cb) {
WSDL.open(wsdlUrl, {}, function(err, wsdl) {
if (err) {
return cb(err);
}
cb(null, wsdl);
});
}
// get services defined in the wsdl
const soap = require('strong-soap').soap;
async function createSoapClient(url, options={}) {
return new Promise(function (resolve, reject) {
soap.createClient(url, options, function(err, client) {
if (err) {
return reject(err)
} else {
return resolve(client)
}
})
})
}
module.exports = {
createSoapClient,
}
return new Promise(function (resolve, reject) {
soap.createClient(url, options, function(err, client) {
if (err) {
return reject(err)
} else {
return resolve(client)
}
})
})
}
SOAPConnector.prototype.connect = function (cb) {
var self = this;
if (self.client) {
process.nextTick(function () {
cb && cb(null, self.client);
});
return;
}
if (debug.enabled) {
debug('Reading wsdl: %s', self.wsdl);
}
soap.createClient(self.wsdl, self.settings, function (err, client) {
if (!err) {
if (debug.enabled) {
debug('wsdl loaded: %s', self.wsdl);
}
if (self.settings.security || self.settings.username) {
var sec = null;
var secConfig = self.settings.security || self.settings;
if (debug.enabled) {
debug('configuring security: %j', secConfig);
}
switch (secConfig.scheme) {
case 'WS':
case 'WSSecurity':
sec = new soap.WSSecurity(secConfig.username, secConfig.password,
secConfig.passwordType || secConfig.options);
break;
} else {
sec = new soap.ClientSSLSecurity(
secConfig.keyPath || secConfig.key,
secConfig.certPath || secConfig.cert,
secConfig.ca || secConfig.caPath,
secConfig.options);
}
break;
case 'Bearer':
sec = new soap.BearerSecurity(
secConfig.token,
secConfig.options);
break;
case 'BasicAuth':
default:
sec = new soap.BasicAuthSecurity(
secConfig.username, secConfig.password, secConfig.options);
break;
}
if (sec) {
client.setSecurity(sec);
}
}
if (self.settings.soapAction || self.settings.SOAPAction) {
client.setSOAPAction(self.settings.soapAction || self.settings.SOAPAction);
}
if (Array.isArray(self.settings.soapHeaders)) {
self.settings.soapHeaders.forEach(function (header) {
if (debug.enabled) {
debug('adding soap header: %j', header);
}
if (secConfig.pfx) {
sec = new soap.ClientSSLSecurityPFX(
secConfig.pfx,
secConfig.passphrase,
secConfig.options
);
} else {
sec = new soap.ClientSSLSecurity(
secConfig.keyPath || secConfig.key,
secConfig.certPath || secConfig.cert,
secConfig.ca || secConfig.caPath,
secConfig.options);
}
break;
case 'Bearer':
sec = new soap.BearerSecurity(
secConfig.token,
secConfig.options);
break;
case 'BasicAuth':
default:
sec = new soap.BasicAuthSecurity(
secConfig.username, secConfig.password, secConfig.options);
break;
}
if (sec) {
client.setSecurity(sec);
}
}
if (self.settings.soapAction || self.settings.SOAPAction) {
client.setSOAPAction(self.settings.soapAction || self.settings.SOAPAction);
}
sec = new soap.WSSecurityCert(
secConfig.privatePEM,
secConfig.publicP12PEM,
secConfig.password,
secConfig.encoding
);
break;
case 'ClientSSL':
if (secConfig.pfx) {
sec = new soap.ClientSSLSecurityPFX(
secConfig.pfx,
secConfig.passphrase,
secConfig.options
);
} else {
sec = new soap.ClientSSLSecurity(
secConfig.keyPath || secConfig.key,
secConfig.certPath || secConfig.cert,
secConfig.ca || secConfig.caPath,
secConfig.options);
}
break;
case 'Bearer':
sec = new soap.BearerSecurity(
secConfig.token,
secConfig.options);
break;
case 'BasicAuth':
default:
sec = new soap.BasicAuthSecurity(
secConfig.username, secConfig.password, secConfig.options);
break;