Comparing version 1.0.6 to 2.0.0
@@ -8,13 +8,19 @@ { | ||
}, | ||
"version": "1.0.6", | ||
"main": "./src/easysoap.js", | ||
"version": "2.0.0", | ||
"main": "./src/index.js", | ||
"dependencies": { | ||
"request": "^2.69.0", | ||
"underscore": "^1.8.3", | ||
"xmldoc": "^0.4.0", | ||
"wsdlrdr": "^0.3.9" | ||
"wsdlrdr": "^0.3.9", | ||
"xmldoc": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"tap-spec": "^4.1.0", | ||
"tape" : "^4.2.2" | ||
"tap-spec": "latest", | ||
"tape": "latest", | ||
"eslint": "latest", | ||
"eslint-config-standard": "latest", | ||
"eslint-plugin-import": "latest", | ||
"eslint-plugin-node": "latest", | ||
"eslint-plugin-promise": "latest", | ||
"eslint-plugin-standard": "latest" | ||
}, | ||
@@ -29,4 +35,4 @@ "keywords": [ | ||
}, | ||
"engines" : { | ||
"node" : ">=4.0.0" | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
@@ -33,0 +39,0 @@ "scripts": { |
191
README.md
@@ -1,27 +0,28 @@ | ||
## What ? | ||
# EasySoap | ||
**easysoap** is a WSDL SoapClient for Node.js. | ||
[![Join the chat at https://gitter.im/moszeed/easysoap](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/moszeed/easysoap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
## How to get ? | ||
install with npm | ||
npm i easysoap | ||
## Usage | ||
## available methods | ||
### get a soapclient instance | ||
#### *createClient* | ||
**params** createParams, soapOptions | ||
**response** instance of easysoap | ||
const EasySoap = require('easysoap'); | ||
const soapClient = EasySoap(params, opts); | ||
**params** createParams, soapOptions | ||
**response** instance of easysoap | ||
##### possible parameter data | ||
*createParams* | ||
{ | ||
host : 'www.example.com', | ||
path : '/soap/path', | ||
wsdl : '/wsdl/path', | ||
headers : Array or Object, | ||
rejectUnauthorized : true/false | ||
{ | ||
host : 'www.example.com', | ||
path : '/soap/path', | ||
wsdl : '/wsdl/path', | ||
headers : Array or Object, | ||
rejectUnauthorized : true/false | ||
} | ||
@@ -31,17 +32,15 @@ | ||
{ | ||
secure : true/false //is https or http | ||
{ | ||
secure : true/false //is https or http | ||
} | ||
###### the following methods available after creating an soapclient instance with *easysoap* | ||
###### the following methods available after getting an *easysoap* instance with "createClient" | ||
#### *call* | ||
**params** callParams | ||
**response** callResponseObject | ||
**params** callParams | ||
**response** callResponseObject | ||
#### *getRequestXml* | ||
**params** callParams | ||
**response** xml (string) | ||
**params** callParams | ||
**response** xml (string) | ||
@@ -51,11 +50,11 @@ *callParams* | ||
{ | ||
method : "sampleMethodName", | ||
attributes: Object of custom tag attributes for given params, | ||
params : Object/Array of params | ||
} | ||
method : "sampleMethodName", | ||
attributes: Object of custom tag attributes for given params, | ||
params : Object/Array of params | ||
} | ||
#### *getXmlDataAsJson* | ||
**params** xml (string) | ||
**response** xmldata as json | ||
**params** xml (string) | ||
**response** xmldata as json | ||
@@ -66,78 +65,74 @@ #### *getAllFunctions* | ||
#### *getMethodParamsByName* | ||
**params** methodName (string) | ||
**params** methodName (string) | ||
**response** methodParams (object) | ||
## How to use ? | ||
## Examples | ||
(function() { | ||
"use strict"; | ||
(() => { | ||
'use strict'; | ||
const EasySoap = require('easysoap'); | ||
var easysoap = require('easysoap'); | ||
// define soap params | ||
var params = { | ||
host : 'www.sample.com', | ||
path : '/path/soap/', | ||
wsdl : '/path/wsdl/, | ||
// define soap params | ||
const params = { | ||
host: 'www.sample.com', | ||
path: '/path/soap/', | ||
wsdl: '/path/wsdl/', | ||
// set soap headers (optional) | ||
headers: [{ | ||
'name' : 'item_name', | ||
'value' : 'item_value', | ||
'namespace': 'item_namespace' | ||
}] | ||
} | ||
/* | ||
* create the client | ||
*/ | ||
var soapClient = easysoap.createClient(params); | ||
/* | ||
* get all available functions | ||
*/ | ||
soapClient.getAllFunctions() | ||
.then((functionArray) => { console.log(functionArray); }) | ||
.catch((err) => { throw new Error(err); }); | ||
// set soap headers (optional) | ||
headers: [{ | ||
'name' : 'item_name', | ||
'value' : 'item_value', | ||
'namespace': 'item_namespace' | ||
}] | ||
} | ||
/* | ||
* get the method params by given methodName | ||
*/ | ||
soapClient.getMethodParamsByName('methodName') | ||
.then((methodParams) => { | ||
console.log(methodParams.request); | ||
console.log(methodParams.respone); | ||
}) | ||
.catch((err) => { throw new Error(err); }); | ||
/* | ||
* create the client | ||
*/ | ||
var soapClient = EasySoap(params); | ||
/* | ||
* call soap method | ||
*/ | ||
soapClient.call({ | ||
method : 'methodName', | ||
attributes: { | ||
xmlns: 'http://www.sample.com' | ||
}, | ||
params: { | ||
testParam: 1, | ||
testParam: [2, 3], | ||
testParam: { | ||
'_value' : 4, | ||
'_attributes': { | ||
'xmlns1': 'http://www.sample.com/other' | ||
} | ||
} | ||
} | ||
}) | ||
.then((callResponse) => { | ||
console.log(callResponse.data); // response data as json | ||
console.log(callResponse.body); // response body | ||
console.log(callResponse.header); //response header | ||
}) | ||
.catch((err) => { throw new Error(err); }); | ||
/* | ||
* get all available functions | ||
*/ | ||
soapClient.getAllFunctions() | ||
.then((functionArray) => { console.log(functionArray); }) | ||
.catch((err) => { throw new Error(err); }); | ||
}(); | ||
/* | ||
* get the method params by given methodName | ||
*/ | ||
soapClient.getMethodParamsByName('methodName') | ||
.then((methodParams) => { | ||
console.log(methodParams.request); | ||
console.log(methodParams.response); | ||
}) | ||
.catch((err) => { throw new Error(err); }); | ||
/* | ||
* call soap method | ||
*/ | ||
soapClient.call({ | ||
method : 'methodName', | ||
attributes: { | ||
xmlns: 'http://www.sample.com' | ||
}, | ||
params: { | ||
testParam: 1, | ||
testParam: [2, 3], | ||
testParam: { | ||
'_value' : 4, | ||
'_attributes': { | ||
'xmlns1': 'http://www.sample.com/other' | ||
} | ||
} | ||
} | ||
}) | ||
.then((callResponse) => { | ||
console.log(callResponse.data); // response data as json | ||
console.log(callResponse.body); // response body | ||
console.log(callResponse.header); //response header | ||
}) | ||
.catch((err) => { throw new Error(err); }); |
@@ -1,19 +0,8 @@ | ||
(function() { | ||
(() => { | ||
'use strict'; | ||
"use strict"; | ||
const test = require('tape'); | ||
const EasySoap = require('..'); | ||
var _ = require('underscore'); | ||
var EasySoap = require('../src/easysoap.js'); | ||
function executeSequentially(promiseFactories) { | ||
var result = Promise.resolve(); | ||
promiseFactories.forEach((promiseFactory) => { | ||
result = result.then(promiseFactory); | ||
}); | ||
return result; | ||
} | ||
var soapTestDataArray = [ | ||
[{ host: 'www.predic8.com:8080', path: '/base/IDService', wsdl: '/base/IDService?wsdl' }], | ||
[{ | ||
@@ -47,194 +36,106 @@ host : 'www.webservicex.net', | ||
var test = require('tape'); | ||
test('createClient', (t) => { | ||
soapTestDataArray.forEach((soapTestDataItem) => { | ||
let connectionData = soapTestDataItem[0]; | ||
let soapOptions = soapTestDataItem[1] || {}; | ||
// | ||
// global tests | ||
// | ||
test('createClient', | ||
(t) => { | ||
let soapClient = EasySoap(connectionData, soapOptions); | ||
soapClients.push({ | ||
'url' : connectionData.host + connectionData.path, | ||
'instance': soapClient | ||
}); | ||
soapTestDataArray.forEach( | ||
(soapTestDataItem) => { | ||
t.ok(true, 'soapClient create for ' + connectionData.host); | ||
}); | ||
var connectionData = soapTestDataItem[0]; | ||
var soapOptions = soapTestDataItem[1] || {}; | ||
t.end(); | ||
}); | ||
var soapClient = EasySoap.createClient(connectionData, soapOptions); | ||
soapClients.push({ | ||
'url' : connectionData.host + connectionData.path, | ||
'instance': soapClient | ||
}); | ||
t.ok(true, 'soapClient create for ' + connectionData.host); | ||
} | ||
) | ||
t.end(); | ||
} | ||
) | ||
test('getAllFunctions', | ||
(t) => { | ||
var promiseFactory = []; | ||
soapClients.forEach((soapClient) => { | ||
promiseFactory.push(() => { | ||
return soapClient.instance.getAllFunctions() | ||
.then((functionArray) => { | ||
var arrLength = functionArray.length; | ||
t.ok(arrLength !== 0, arrLength + ' functions (' + soapClient.url + ')'); | ||
}); | ||
}); | ||
} | ||
); | ||
executeSequentially(promiseFactory) | ||
.then(() => { t.end(); }) | ||
.catch((err) => { t.end(err); }); | ||
} | ||
) | ||
// | ||
// specific tests | ||
// | ||
test('www.predic8.com:8080/base/IDService', | ||
(t) => { | ||
var soapClient = _.findWhere(soapClients, { 'url': 'www.predic8.com:8080/base/IDService' }); | ||
if (!soapClient) { | ||
t.end('no soap client available'); | ||
} | ||
soapClient.instance.call({ | ||
method: 'generate', | ||
params: '123' | ||
test('getAllFunctions', async (t) => { | ||
try { | ||
const runtime = soapClients.map( | ||
(soapClient) => soapClient.instance.getAllFunctions().then((functionArray) => { | ||
var arrLength = functionArray.length; | ||
t.ok(arrLength !== 0, `${arrLength} functions (${soapClient.instance._params.host})`); | ||
}) | ||
.then((data) => { | ||
t.ok(data.data.id !== void 0, 'calling "generate" successful'); | ||
t.end(); | ||
}) | ||
.catch((err) => { t.end(err); }); | ||
} | ||
) | ||
); | ||
await Promise.all(runtime); | ||
test('www.webservicex.net/globalweather.asmx', | ||
(t) => { | ||
t.end(); | ||
} catch (err) { | ||
t.end(err); | ||
} | ||
}); | ||
var soapClient = _.findWhere(soapClients, { 'url': 'www.webservicex.net/globalweather.asmx' }); | ||
if (!soapClient) { | ||
t.end('no soap client available'); | ||
} | ||
soapClient.instance.call({ | ||
method : 'GetWeather', | ||
attributes: { | ||
xmlns: "http://www.webserviceX.NET" | ||
}, | ||
params: { | ||
'CityName' : 'Leipzig-Schkeuditz', | ||
'CountryName': 'Germany' | ||
} | ||
}) | ||
.then((data) => { | ||
var weatherData = soapClient.instance.getXmlDataAsJson( | ||
data.data.GetWeatherResponse.GetWeatherResult | ||
); | ||
t.ok(weatherData.CurrentWeather.length !== 0, 'got some weather data'); | ||
t.end(); | ||
}) | ||
.catch((err) => { t.end(err); }); | ||
test('www.dataaccess.com/webservicesserver/numberconversion.wso', async (t) => { | ||
try { | ||
const soapClient = soapClients.find((item) => item.url === 'www.dataaccess.com/webservicesserver/numberconversion.wso'); | ||
if (!soapClient) { | ||
t.end('no soap client available'); | ||
} | ||
) | ||
test('webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso', | ||
(t) => { | ||
var soapClient = _.findWhere(soapClients, { | ||
'url': 'webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso' | ||
}); | ||
if (!soapClient) { | ||
t.end('no soap client available'); | ||
const response = await soapClient.instance.call({ | ||
method : 'NumberToDollars', | ||
attributes: { | ||
xmlns: 'http://www.dataaccess.com/webservicesserver/' | ||
}, | ||
params: { | ||
'dNum': 255 | ||
} | ||
}); | ||
soapClient.instance.call({ | ||
method : 'FullCountryInfo', | ||
attributes: { | ||
xmlns: "http://www.oorsprong.org/websamples.countryinfo" | ||
}, | ||
params: { | ||
'sCountryISOCode': 'DE' | ||
} | ||
}) | ||
.then((data) => { | ||
t.ok(data.data.FullCountryInfoResponse.FullCountryInfoResult.length !== 0, 'country info recieved'); | ||
t.end(); | ||
}) | ||
.catch((err) => { t.end(err); }); | ||
t.ok(response.data.NumberToDollarsResponse.NumberToDollarsResult, 'got a number conversion'); | ||
t.end(); | ||
} catch (err) { | ||
t.end(err); | ||
} | ||
}); | ||
test('webservices.daehosting.com/services/isbnservice.wso', async (t) => { | ||
try { | ||
const soapClient = soapClients.find((item) => item.url === 'webservices.daehosting.com/services/isbnservice.wso'); | ||
if (!soapClient) { | ||
t.end('no soap client available'); | ||
} | ||
); | ||
test('webservices.daehosting.com/services/isbnservice.wso', | ||
(t) => { | ||
var soapClient = _.findWhere(soapClients, { | ||
'url': 'webservices.daehosting.com/services/isbnservice.wso' | ||
}); | ||
if (!soapClient) { | ||
t.end('no soap client available'); | ||
const response = await soapClient.instance.call({ | ||
method : 'IsValidISBN10', | ||
attributes: { | ||
xmlns: 'http://webservices.daehosting.com/ISBN' | ||
}, | ||
params: { | ||
'sISBN': '1491904240' | ||
} | ||
}); | ||
soapClient.instance.call({ | ||
method : 'IsValidISBN10', | ||
attributes: { | ||
xmlns: "http://webservices.daehosting.com/ISBN" | ||
}, | ||
params: { | ||
'sISBN': '1491904240' | ||
} | ||
}) | ||
.then((data) => { | ||
t.ok(data.data.IsValidISBN10Response.IsValidISBN10Result, 'checked ISBN'); | ||
t.end(); | ||
}) | ||
.catch((err) => { t.end(err); }); | ||
t.ok(response.data.IsValidISBN10Response.IsValidISBN10Result, 'checked ISBN'); | ||
t.end(); | ||
} catch (err) { | ||
t.end(err); | ||
} | ||
}); | ||
test('webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso', async (t) => { | ||
try { | ||
const soapClient = soapClients.find((item) => item.url === 'webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso'); | ||
if (!soapClient) { | ||
t.end('no soap client available'); | ||
} | ||
); | ||
test('www.dataaccess.com/webservicesserver/numberconversion.wso', | ||
(t) => { | ||
var soapClient = _.findWhere(soapClients, { | ||
'url': 'www.dataaccess.com/webservicesserver/numberconversion.wso' | ||
}); | ||
if (!soapClient) { | ||
t.end('no soap client available'); | ||
const response = await soapClient.instance.call({ | ||
method : 'FullCountryInfo', | ||
attributes: { | ||
xmlns: 'http://www.oorsprong.org/websamples.countryinfo' | ||
}, | ||
params: { | ||
'sCountryISOCode': 'DE' | ||
} | ||
}); | ||
soapClient.instance.call({ | ||
method : 'NumberToDollars', | ||
attributes: { | ||
xmlns: "http://www.dataaccess.com/webservicesserver/" | ||
}, | ||
params: { | ||
'dNum': 255 | ||
} | ||
}) | ||
.then((data) => { | ||
t.ok(data.data.NumberToDollarsResponse.NumberToDollarsResult, 'got a number conversion'); | ||
t.end(); | ||
}) | ||
.catch((err) => { t.end(err); }); | ||
} | ||
); | ||
t.ok(response.data.FullCountryInfoResponse.FullCountryInfoResult.length !== 0, 'country info recieved'); | ||
t.end(); | ||
} catch (err) { | ||
t.end(err); | ||
} | ||
}); | ||
})(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
22637
8
10
409
136
1
+ Addedsax@1.4.1(transitive)
+ Addedxmldoc@1.3.0(transitive)
Updatedxmldoc@^1.1.0