Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

soap

Package Overview
Dependencies
Maintainers
4
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

soap - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

0

CONTRIBUTING.md

@@ -0,0 +0,0 @@ #Contribution Guidelines

32

History.md

@@ -0,17 +1,49 @@

0.9.1 / 2015-05-30
=================
* [FIX] Received empty Strings are now returned as empty String rather than an empty Object. (#637)
* [FIX] Get current namespace when parent namespace is an empty String. Fixes #533. (#661)
* [DOC] Update README.md with documentation for #660 introduced customization of `httpClient` and `request` libs in `client.options`. (#664)
* [FIX] Take configured "ignored namespaces" into account when processing `objectToXml()`. Fixes #537. (#662)
* [LIC] Update license attribute to follow the new [npm conventions](https://docs.npmjs.com/files/package.json#license). (#663)
* [ENHANCEMENT] Add ability to customize `http` client / `request` lib on client creation. (#660)
* [FIX] Support `xsi:type` Schema on Element. Fixes #606. (#639)
* [FIX] Make parsing of recursive Elements in `wsdl` work. (#658)
0.9.0 / 2015-05-18
=================
* [FIX] Fix to allow request options and headers to persist for all includes. Fix to properly handle when an import/include starts with a schema element. (#608)
* [FIX] Do not end request for keep-alive connections (#600)
* [ENHANCEMENT] Added Client 'response' event (#610)
* [FIX] If response is json, then error should not be thrown. Fix issue #580 (#581)
* [FIX] Sub-namespace should be correct regardless of order of enumeration i.e. should not be overriden by other prop's namespace (#607)
* [DOC] Added a section about Server Events to README.md (#596)
* [ENHANCEMENT] Added Server 'request' event (#595)
* [ENHANCEMENT] Add support for One-Way Operations (#590)
* [FIX] `lib/wsdl.js` util function `extend()` doesn't throw an Error when handling elements that are not objects. (#589)
* [ENHANCEMENT] ClientSSLSecurity now accepts a `ca`-certificate. (#588)
* [ENHANCEMENT] ClientSSLSecurity should be able to take a Buffer as `key` and `cert` parameter. Additionally the certificates are checked whether they are correct or not (starting with `-----BEGIN`). (#586)
* [ENHANCEMENT] Add support for sending NULL values (#578)
* [ENHANCEMENT] Follow 302 redirects, don't mix quotes (#577)
* [DOC] Update CONTRIBUTING.md
* [FIX] Respond with security timestamp if request had one (#579)

@@ -18,0 +50,0 @@

"use strict";
module.exports = require('./lib/soap');

15

lib/client.js

@@ -14,3 +14,3 @@ /*

var http = require('./http'),
var HttpClient = require('./http'),
assert = require('assert'),

@@ -29,2 +29,3 @@ events = require('events'),

this._initializeServices(endpoint);
this.httpClient = options.httpClient || new HttpClient(options);
};

@@ -214,2 +215,3 @@ util.inherits(Client, events.EventEmitter);

self.lastRequest = xml;
self.lastEndpoint = location;

@@ -219,3 +221,3 @@ self.emit('message', message);

req = http.request(location, xml, function(err, response, body) {
req = self.httpClient.request(location, xml, function(err, response, body) {
var result;

@@ -250,2 +252,9 @@ var obj;

if( typeof obj.Body !== 'object' ) {
var error = new Error('Cannot parse response');
error.response = response;
error.body = body;
return callback(error, obj, body);
}
result = obj.Body[output.$name];

@@ -268,3 +277,3 @@ // RPC/literal response body may contain elements with added suffixes I.E.

}
}, headers, options);
}, headers, options, self);

@@ -271,0 +280,0 @@ // Added mostly for testability, but possibly useful for debugging

@@ -10,6 +10,27 @@ /*

var req = require('request');
var debug = require('debug')('node-soap');
var VERSION = require('../package.json').version;
var httpRequest = function httpRequest(rurl, data, callback, exheaders, exoptions) {
/**
* A class representing the http client
* @param {Object} [options] Options object. It allows the customization of
* `request` module
*
* @constructor
*/
function HttpClient(options) {
options = options || {};
this._request = options.request || req;
}
/**
* Build the HTTP request (method, uri, headers, ...)
* @param {String} rurl The resource url
* @param {Object|String} data The payload
* @param {Object} exheaders Extra http headers
* @param {Object} exoptions Extra options
* @returns {Object} The http request object for the `request` module
*/
HttpClient.prototype.buildRequest = function(rurl, data, exheaders, exoptions) {
var curl = url.parse(rurl);

@@ -23,3 +44,3 @@ var secure = curl.protocol === 'https:';

'User-Agent': 'node-soap/' + VERSION,
'Accept' : 'text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8',
'Accept': 'text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'none',

@@ -38,3 +59,5 @@ 'Accept-Charset': 'utf-8',

exheaders = exheaders || {};
for (attr in exheaders) { headers[attr] = exheaders[attr]; }
for (attr in exheaders) {
headers[attr] = exheaders[attr];
}

@@ -47,3 +70,3 @@ var options = {

};
if (headers.Connection === 'keep-alive') {

@@ -54,28 +77,46 @@ options.body = data;

exoptions = exoptions || {};
for (attr in exoptions) { options[attr] = exoptions[attr]; }
for (attr in exoptions) {
options[attr] = exoptions[attr];
}
debug('Http request: %j', options);
return options;
};
var request = req(options, function (error, res, body) {
if (error) {
callback(error);
} else {
if (typeof body === 'string') {
// Remove any extra characters that appear before or after the SOAP
// envelope.
var match = body.match(/(?:<\?[^?]*\?>[\s]*)?<([^:]*):Envelope([\S\s]*)<\/\1:Envelope>/i);
if (match) {
body = match[0];
}
}
request.on('error', callback);
callback(null, res, body);
/**
* Handle the http response
* @param {Object} The req object
* @param {Object} res The res object
* @param {Object} body The http body
* @param {Object} The parsed body
*/
HttpClient.prototype.handleResponse = function(req, res, body) {
debug('Http response body: %j', body);
if (typeof body === 'string') {
// Remove any extra characters that appear before or after the SOAP
// envelope.
var match = body.match(/(?:<\?[^?]*\?>[\s]*)?<([^:]*):Envelope([\S\s]*)<\/\1:Envelope>/i);
if (match) {
body = match[0];
}
}
return body;
};
HttpClient.prototype.request = function(rurl, data, callback, exheaders, exoptions) {
var self = this;
var options = self.buildRequest(rurl, data, exheaders, exoptions);
var headers = options.headers;
var req = self._request(options, function(err, res, body) {
if (err) {
return callback(err);
}
body = self.handleResponse(req, res, body);
callback(null, res, body);
});
if (headers.Connection !== 'keep-alive') {
request.end(data);
req.end(data);
}
return request;
return req;
};
exports.request = httpRequest;
module.exports = HttpClient;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -270,3 +270,3 @@ /*

function handleResult(result) {
function handleResult(error, result) {
if (handled)

@@ -276,2 +276,11 @@ return;

if (error && error.Fault !== undefined) {
var fault = self.wsdl.objectToDocumentXML("Fault", error.Fault, "soap");
return callback(self._envelope(fault, includeTimestamp));
}
else if (result === undefined) {
// Backward compatibility to support one argument callback style
result = error;
}
if (style === 'rpc') {

@@ -278,0 +287,0 @@ body = self.wsdl.objectToRpcXML(outputName, result, '', self.wsdl.definitions.$targetNamespace);

@@ -10,2 +10,3 @@ /*

Server = require('./server').Server,
HttpClient = require('./http'),
security = require('./security'),

@@ -78,1 +79,6 @@ passwordDigest = require('./utils').passwordDigest,

exports.WSDL = WSDL;
// Export Client and Server to allow customization
exports.Server = Server;
exports.Client = Client;
exports.HttpClient = HttpClient;

@@ -0,0 +0,0 @@

@@ -12,3 +12,3 @@ /*

var inherits = require('util').inherits;
var http = require('./http');
var HttpClient = require('./http');
var fs = require('fs');

@@ -432,3 +432,4 @@ var url = require('url');

if (child instanceof TypesElement) {
self.schemas = child.schemas;
// Merge types.schemas into definitions.schemas
_.merge(self.schemas, child.schemas);
}

@@ -874,7 +875,17 @@ else if (child instanceof MessageElement) {

definitions.descriptions.types[typeName] = elem;
var description = typeElement.description(definitions, xmlns);
if (typeof description === 'string') {
elem = description;
}
else {
Object.keys(description).forEach(function (key) {
elem[key] = description[key];
});
}
if (this.$ref) {
elem = element = typeElement.description(definitions, xmlns);
element = elem;
}
else {
elem = element[name] = typeElement.description(definitions, xmlns);
element[name] = elem;
}

@@ -1068,3 +1079,2 @@

WSDL.prototype.ignoredNamespaces = ['tns', 'targetNamespace', 'typedNamespace'];
WSDL.prototype._ignoredSchemaNamespaces = ['tns', 'xs', 'xsd'];

@@ -1153,33 +1163,2 @@ WSDL.prototype.valueKey = '$value';

/**
* Returns true if a schema namespace needs to be ignored.
*
* @method shouldIgnoreNamespace
* @param {Object} schema The parsed WSDL Schema object.
*/
WSDL.prototype.shouldIgnoreNamespace = function(schema) {
if (schema && typeof schema.xmlns === 'object') {
// get the keys from schema.xmlns object (something like xs, xsd or custom)
var schemaXmlns = Object.keys(schema.xmlns);
var schemaXmlnsLength = schemaXmlns.length;
if (schemaXmlnsLength > 0) {
var count = 0;
// loop through the keys
for (var key in schemaXmlns) {
var xmlns = schemaXmlns[key];
// if the key exists in the default ignoredSchemaNamespaces, add it to the count
if (this._ignoredSchemaNamespaces.indexOf(xmlns) > -1) {
count++;
}
}
// if the count is equal to the length, don't add the namespace
if(count === schemaXmlnsLength) {
return true;
}
}
}
return false;
};
WSDL.prototype.toXML = function() {

@@ -1299,5 +1278,16 @@ return this.xml || '';

// Pick up the schema for the type specified in element's xsi:type attribute.
var xsiTypeSchema;
var xsiType = elementAttributes['xsi:type'];
if (xsiType) {
var type = splitNSName(xsiType);
var typeDef = self.findParameterObject(xmlns[type.namespace], type.name);
if (typeDef) {
xsiTypeSchema = typeDef.description(self.definitions);
}
}
if (topSchema && topSchema[name + '[]'])
name = name + '[]';
stack.push({name: originalName, object: obj, schema: topSchema && topSchema[name], id: attrs.id, nil: hasNilAttribute});
stack.push({name: originalName, object: obj, schema: (xsiTypeSchema || (topSchema && topSchema[name])), id: attrs.id, nil: hasNilAttribute});
};

@@ -1313,2 +1303,6 @@

if (typeof cur.schema === 'string' && (cur.schema === 'string' || cur.schema.split(':')[1] === 'string')) {
if (typeof obj === 'object' && Object.keys(obj).length === 0) obj = cur.object = '';
}
if(cur.nil === true) {

@@ -1318,2 +1312,3 @@ return;

if (topSchema && topSchema[name + '[]']) {

@@ -1480,3 +1475,3 @@ if (!topObject[name])

var parentNamespace = namespace ? namespace.parent : undefined;
if(parentNamespace) {
if(typeof parentNamespace !== 'undefined') {
//we got the parentNamespace for our array. setting the namespace-variable back to the current namespace string

@@ -1490,3 +1485,2 @@ namespace = namespace.current;

var prefixNamespace = (namespace || qualified) && namespace !== 'xmlns';
var isNamespaceIgnored = this.shouldIgnoreNamespace(schema);

@@ -1496,3 +1490,3 @@ var xmlnsAttrib = '';

if (prefixNamespace && (!isNamespaceIgnored || this.ignoredNamespaces.indexOf(namespace) === -1)) {
if (prefixNamespace && this.options.ignoredNamespaces.indexOf(namespace) === -1) {
// resolve the prefix namespace

@@ -1513,3 +1507,3 @@ xmlnsAttrib += ' xmlns:' + namespace + '="' + xmlns + '"';

var ns = '';
if (prefixNamespace && ((qualified || first) || soapHeader) && (!isNamespaceIgnored || this.ignoredNamespaces.indexOf(namespace) === -1)) {
if (prefixNamespace && ((qualified || first) || soapHeader) && this.options.ignoredNamespaces.indexOf(namespace) === -1) {
// prefix element

@@ -1818,2 +1812,3 @@ ns = namespace.indexOf(":") === -1 ? namespace + ':' : namespace;

case "http://schemas.xmlsoap.org/wsdl/soap/" : // wsdlsoap
case "http://schemas.xmlsoap.org/wsdl/soap12/": // wsdlsoap12
case "http://schemas.xmlsoap.org/soap/encoding/" : // soapenc

@@ -1845,2 +1840,3 @@ case "http://www.w3.org/2001/XMLSchema" : // xsd

if (!/^http/.test(uri)) {
debug('Reading file: %s', uri);
fs.readFile(uri, 'utf8', function(err, definition) {

@@ -1857,3 +1853,5 @@ if (err) {

else {
http.request(uri, null /* options */, function(err, response, definition) {
debug('Reading url: %s', uri);
var httpClient = new HttpClient(options);
httpClient.request(uri, null /* options */, function(err, response, definition) {
if (err) {

@@ -1860,0 +1858,0 @@ callback(err);

{
"name": "soap",
"version": "0.9.0",
"version": "0.9.1",
"description": "A minimal node SOAP client",

@@ -31,8 +31,3 @@ "engines": {

],
"licenses": [
{
"type": "MIT License",
"url": "http://www.opensource.org/licenses/mit-license.php"
}
],
"license": "MIT",
"devDependencies": {

@@ -39,0 +34,0 @@ "mocha": "~1.17.0",

@@ -0,0 +0,0 @@ Publishing

@@ -36,4 +36,10 @@ # Soap [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url]

Within the options object you may provide an `endpoint` property in case you want to override the SOAP service's host specified in the `.wsdl` file.
#### Options
The `options` argument allows you to customize the client with the following properties:
- endpoint: to override the SOAP service's host specified in the `.wsdl` file.
- request: to override the [request](https://github.com/request/request) module.
- httpClient: to provide your own http client that implements `request(rurl, data, callback, exheaders, exoptions)`.
### soap.listen(*server*, *path*, *services*, *wsdl*) - create a new SOAP server that listens on *path* and provides *services*.

@@ -40,0 +46,0 @@ *wsdl* is an xml string that defines the service.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc