Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing '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.
constructor (port = 8000) {
this.port = port;
this.soapService = soapService;
this.wsdlXML = wsdlXML;
const server = this.server = http.createServer((request, response) => {
response.end('404: Not Found: ' + request.url);
});
this.soapServer = SOAP.listen(server, '/default.asmx', this.soapService, this.wsdlXML);
//Use this for debugging if needed
// this.soapServer.on('request', (req, methodName) => {
// console.log('reqest', methodName);
// });
}
function testsoap() {
var soap = require('soap');
soap.createClient(gSkopeiURL, function(err, client) {
// var info = client.describe();
// var args = {Text: 'hahahoho'};
// add_authentication(args);
// client.TestWebservice(args, function(err, result) {
// if(err) {
// log_line('TestWebservice - error ' + err);
// } else {
// log_line(result);
// }
// });
var args = { ElockID: "170178"}; // , PeriodTill: '2017-04-30T23:59:59Z'}
add_authentication(args);
let soapClient: soap.Client = await new Promise((resolve: (soapClient: soap.Client,) => any, reject) => {
soap.createClient(url, (err, client: soap.Client) => {
// console.log('callback', err)
// console.log('keys', _.keys(client))
if (err) reject(err)
else resolve(client)
})
})
TrackService.prototype.init = function init(callback) {
var self = this;
// Ignore self signed certificate error
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
soap.createClient(WSDL_PATH, {endpoint: ENDPOINT}, function(err, client) {
if (err) {
return callback(err);
}
updateSecurity(client);
updateToken(client);
var args = {
user: self.defaultArgs.user,
password: self.defaultArgs.password,
deviceType: self.defaultArgs.deviceType,
lastmessage: "",
lang: self.defaultArgs.lang
};
client.MessageBoardJson(args, function(err, res) {
sfClient.getIdentity({ oauth: oauth }, function(err, res) {
if(err) return cb(err);
soap.createClient(mdWsdl, function(err, client) {
if(err) return cb(err);
//client.setSecurity(new soap.BearerSecurity(oauth.access_token));
var header = {
'SessionHeader': {
'sessionId': oauth.access_token
}
};
var name = '';
var xmlns = 'http://soap.sforce.com/2006/04/metadata';
var ns = 'urn';
//
client.addSoapHeader(header, name, ns, xmlns);
// var header = [
// '',
/* eslint camelcase: "off" */
import { DateTime } from 'luxon'
import { createClientAsync } from 'soap'
const WSDL_URL = 'http://rtpi.dublinbus.ie/DublinBusRTPIService.asmx?WSDL'
const clientPromise = createClientAsync(WSDL_URL)
interface GetRealTimeStopDataOptions {
readonly stopId: number
readonly forceRefresh: boolean
}
interface GetRealTimeStopDataResponse {
readonly GetRealTimeStopDataResult: {
readonly diffgram: {
readonly DocumentElement: {
readonly StopData: Array<{
ServiceDelivery_ResponseTimestamp: string
MonitoredVehicleJourney_PublishedLineName: string
MonitoredVehicleJourney_DestinationName: string
MonitoredCall_ExpectedArrivalTime: string
MonitoredCall_VehicleAtStop: string
export const getClientInternal = async (
opts: ClientOptions
): Promise => {
const authOptions = opts.credentials ? makeAuthOptions(opts.credentials) : {}
const defaultOptions = { rejectUnauthorized: false, strictSSL: false }
const endpoint = getEndpoint(opts)
const options: IOptions = {
endpoint,
...defaultOptions,
...authOptions,
}
const client: T = await createClientAsync(opts.wsdlPath, options)
// note: the options endpoint and setEndpoint seem to set different values
// within the client. Setting both seems to work best :-B
client.setEndpoint(endpoint)
opts.credentials && setSecurity(client, opts.credentials)
return client
}
return promise((resolve, reject) => {
// for the includes specified in the XML, the uri must be specified and set to the same location as the main EWS services.wsdl
options.uri = wsdlFilePath;
// replace the default blank location with the location of the EWS server uri
options.xml = options.xml.replace('soap:address location=""','soap:address location="'+ ews.urlApi + '"');
// create the basic http server
var server = require('http').createServer(function(request, response) {
response.end('404: Not Found: ' + request.url);
});
// start the server
server.listen(options.port);
// resolve the service with soap.listen
resolve(soap.listen(server, options));
})
});
const BasicAuth = function(config, options) {
if(typeof config === 'object'
&& _.has(config, 'host')
&& _.has(config, 'username')
&& _.has(config, 'password')
) {
return {
wsdlOptions: {},
authProfile: new soap.BasicAuthSecurity(config.username, config.password, options),
getUrl: function(url, filePath) {
// request options
let requestOptions = { 'auth': { 'user': config.username, 'pass': config.password, 'sendImmediately': false } };
requestOptions = _.merge(requestOptions, _.clone(options));
requestOptions.url = url;
return when.promise((resolve, reject) => {
request(requestOptions, function(err, res, body) {
if(err) reject(err);
else if(res.statusCode == 401) reject(new Error('Basic Auth StatusCode 401: Unauthorized.'));
else fs.writeFile(filePath, body, function(err) {
if(err) reject(err);
else resolve(filePath);
});
});
});
const BearerAuth = function(config, options) {
if(typeof config === 'object'
&& _.has(config, 'host')
&& _.has(config, 'username')
&& _.has(config, 'token')
) {
return {
wsdlOptions: {},
authProfile: new soap.BearerSecurity(config.token, options),
getUrl: function(url, filePath) {
// request options
let requestOptions = {
auth: {
bearer: config.token
}
};
requestOptions = _.merge(requestOptions, _.clone(options));
requestOptions.url = url;
return when.promise((resolve, reject) => {
request(requestOptions, function(err, res, body) {
if(err) reject(err);
else if(res.statusCode == 401) reject(new Error('Bearer Auth StatusCode 401: Unauthorized.'));
else fs.writeFile(filePath, body, function(err) {
if(err) reject(err);