Socket
Socket
Sign inDemoInstall

soap

Package Overview
Dependencies
Maintainers
3
Versions
95
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.43.0 to 0.44.0

13

History.md

@@ -0,1 +1,14 @@

0.44.0 / 2022-06-06
===================
* [DOC] Readme.md: Rewrite how to get support for conciseness, update mentions of the old request module to Axios, improve documentation of several functions' arguments. (#1175)
* [ENHANCEMENT] Added override constructor to ClientSSLSecurityPFX class (#1184)
* [ENHANCEMENT] add optional targetNamespace to output message name (#1176)
* [FIX] Change axios to be a peer dependency (#1179)
* [FIX] Continuation PR #1169: change content-type-parser to whatwg-mimetype (#1177)
* [FIX] Fix missing parameter in example (#1172)
* [FIX] Fix of client events behavior (#1181)
* [FIX] correctly serialize MTOM into axios data and add Content-Encoding: gzip support in soap request (#1173)
* [FIX] double await in async and fixed response (#1185)
* [FIX] package.json: Change value of engines.node key from ">=10.0.0" to ">=12.0.0". (#1178)
0.43.0 / 2021-11-12

@@ -2,0 +15,0 @@ ===================

24

lib/client.js

@@ -326,14 +326,2 @@ "use strict";

options = options || {};
// Add extra headers
if (this.httpHeaders === null) {
headers = {};
}
else {
for (var header in this.httpHeaders) {
headers[header] = this.httpHeaders[header];
}
for (var attr in extraHeaders) {
headers[attr] = extraHeaders[attr];
}
}
// Allow the security object to add headers

@@ -399,2 +387,14 @@ if (this.security && this.security.addHeaders) {

this.emit('request', xml, eid);
// Add extra headers
if (this.httpHeaders === null) {
headers = {};
}
else {
for (var header in this.httpHeaders) {
headers[header] = this.httpHeaders[header];
}
for (var attr in extraHeaders) {
headers[attr] = extraHeaders[attr];
}
}
var tryJSONparse = function (body) {

@@ -401,0 +401,0 @@ try {

@@ -21,6 +21,7 @@ "use strict";

var axios_ntlm_1 = require("axios-ntlm");
var contentTypeParser = require("content-type-parser");
var debugBuilder = require("debug");
var url = require("url");
var uuid_1 = require("uuid");
var MIMEType = require("whatwg-mimetype");
var zlib_1 = require("zlib");
var utils_1 = require("./utils");

@@ -97,3 +98,4 @@ var debug = debugBuilder('node-soap');

}
headers['Content-Type'] = 'multipart/related; type="application/xop+xml"; start="<' + start + '>"; start-info="text/xml"; boundary=' + uuid_1.v4();
var boundary_1 = uuid_1.v4();
headers['Content-Type'] = 'multipart/related; type="application/xop+xml"; start="<' + start + '>"; type="text/xml"; boundary=' + boundary_1;
if (action) {

@@ -116,3 +118,14 @@ headers['Content-Type'] = headers['Content-Type'] + '; ' + action;

});
// options.multipart = multipart;
options.data = "--" + boundary_1 + "\r\n";
var multipartCount_1 = 0;
multipart_1.forEach(function (part) {
Object.keys(part).forEach(function (key) {
if (key !== 'body') {
options.data += key + ": " + part[key] + "\r\n";
}
});
options.data += '\r\n';
options.data += part.body + "\r\n--" + boundary_1 + (multipartCount_1 === multipart_1.length - 1 ? '--' : '') + "\r\n";
multipartCount_1++;
});
}

@@ -122,2 +135,8 @@ else {

}
if (exoptions.forceGzip) {
options.decompress = true;
options.data = zlib_1.gzipSync(options.data);
options.headers['Accept-Encoding'] = 'gzip,deflate';
options.headers['Content-Encoding'] = 'gzip';
}
for (var attr in newExoptions) {

@@ -182,5 +201,5 @@ if (mergeOptions.indexOf(attr) !== -1) {

var boundary = void 0;
var parsedContentType = contentTypeParser(res.headers['content-type']);
if (parsedContentType && parsedContentType.parameterList) {
boundary = (parsedContentType.parameterList.find(function (item) { return item.key === 'boundary'; }) || {}).value;
var parsedContentType = MIMEType.parse(res.headers['content-type']);
if (parsedContentType) {
boundary = parsedContentType.parameters.get('boundary');
}

@@ -187,0 +206,0 @@ if (!boundary) {

@@ -16,4 +16,5 @@ /// <reference types="node" />

constructor(pfx: string | Buffer, defaults?: any);
constructor(pfx: string | Buffer, passphrase: string, defaults?: any);
toXML(): string;
addOptions(options: any): void;
}

@@ -479,6 +479,17 @@ "use strict";

}
else {
else if (style === 'document') {
var element = binding.methods[methodName].output;
body = _this_1.wsdl.objectToDocumentXML(outputName, result, element.targetNSAlias, element.targetNamespace);
}
else {
var element = binding.methods[methodName].output;
// Check for targetNamespace on the element
var elementTargetNamespace = element.$targetNamespace;
var outputNameWithNamespace = outputName;
if (elementTargetNamespace) {
// if targetNamespace is set on the element concatinate it with the outputName
outputNameWithNamespace = elementTargetNamespace + ":" + outputNameWithNamespace;
}
body = _this_1.wsdl.objectToDocumentXML(outputNameWithNamespace, result, element.targetNSAlias, element.targetNamespace);
}
callback(_this_1._envelope(body, headers, includeTimestamp));

@@ -485,0 +496,0 @@ };

{
"name": "soap",
"version": "0.43.0",
"version": "0.44.0",
"description": "A minimal node SOAP client",
"engines": {
"node": ">=10.0.0"
"node": ">=12.0.0"
},
"author": "Vinay Pulim <v@pulim.com>",
"dependencies": {
"axios": "^0.21.1",
"axios-ntlm": "^1.2.0",
"content-type-parser": "^1.0.2",
"debug": "^4.3.2",

@@ -20,4 +18,8 @@ "formidable": "^1.2.2",

"uuid": "^8.3.2",
"whatwg-mimetype": "3.0.0",
"xml-crypto": "^2.1.3"
},
"peerDependencies": {
"axios": "^0.21.1"
},
"repository": {

@@ -57,2 +59,3 @@ "type": "git",

"@types/uuid": "^8.3.1",
"@types/whatwg-mimetype": "^2.1.1",
"body-parser": "^1.15.2",

@@ -59,0 +62,0 @@ "colors": "^1.3.3",

@@ -11,7 +11,5 @@ # Soap [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]

- [Features:](#features)
- [Install](#install)
- [Why can't I file an issue?](#why-cant-i-file-an-issue)
- [Where can I find help?](#where-can-i-find-help)
- [Support](#support)
- [Module](#module)

@@ -21,3 +19,3 @@ - [soap.createClient(url[, options], callback) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.](#soapcreateclienturl-options-callback---create-a-new-soap-client-from-a-wsdl-url-also-supports-a-local-filesystem-path)

- [soap.listen(*server*, *path*, *services*, *wsdl*, *callback*) - create a new SOAP server that listens on *path* and provides *services*.](#soaplistenserver-path-services-wsdl-callback---create-a-new-soap-server-that-listens-on-path-and-provides-services)
- [Options](#options)
- [soap.listen(*server*, *options*) - create a new SOAP server that listens on *path* and provides *services*.](#soaplistenserver-options---create-a-new-soap-server-that-listens-on-path-and-provides-services)
- [Server Logging](#server-logging)

@@ -81,9 +79,7 @@ - [Server Events](#server-events)

* Support for both synchronous and asynchronous method handlers
* WS-Security (currently only UsernameToken and PasswordText encoding is supported)
* Supports [express](http://expressjs.com/) based web server(body parser middleware can be used)
* WS-Security UsernameToken Profile 1.0
* Supports [Express](http://expressjs.com/) based web server (body parser middleware can be used)
## Install
Install with [npm](http://github.com/isaacs/npm):
```

@@ -93,14 +89,10 @@ npm install soap

## Why can't I file an issue?
## Support
We've disabled issues in the repository and are now solely reviewing pull requests. The reasons why we disabled issues can be found here [#731](https://github.com/vpulim/node-soap/pull/731).
Community support is available at Gitter: [![Gitter chat][gitter-image]][gitter-url]
## Where can I find help?
Some maintainers provide paid support, which can be request through our [Google Form](https://docs.google.com/forms/d/e/1FAIpQLSdj5EXxd5flcukLInmpFQhEvQYeERaReFFh9F0nqC_4EUmeLg/viewform)
Community support can be found on gitter:
GitHub issues have been disabled to focus on pull requests. ([#731](https://github.com/vpulim/node-soap/pull/731))
[![Gitter chat][gitter-image]][gitter-url]
If you're looking for professional help you can contact the maintainers through this [google form](https://docs.google.com/forms/d/e/1FAIpQLSdj5EXxd5flcukLInmpFQhEvQYeERaReFFh9F0nqC_4EUmeLg/viewform).
## Module

@@ -110,2 +102,29 @@

- `url` (*string*): A HTTP/HTTPS URL or a local filesystem path.
- `options` (*Object*):
- `endpoint` (*string*): Override the host specified by the SOAP service in the WSDL file.
- `envelopeKey` (*string*): Set a custom envelope key. (**Default:** `'soap'`)
- `preserveWhitespace` (*boolean*): Preserve any leading and trailing whitespace characters in text and cdata.
- `escapeXML` (*boolean*): Escape special XML characters (e.g. `&`, `>`, `<` etc) in SOAP messages. (**Default:** `true`)
- `suppressStack` (*boolean*): Suppress the full stack trace for error messages.
- `returnFault` (*boolean*): Return an `Invalid XML` SOAP fault upon a bad request. (**Default:** `false`)
- `forceSoap12Headers` (*boolean*): Enable SOAP 1.2 compliance.
- `httpClient` (*Object*): Override the built-in HttpClient object with your own. Must implement `request(rurl, data, callback, exheaders, exoptions)`.
- `request` (*Object*): Override the default request module ([Axios](https://axios-http.com/) as of `v0.40.0`).
- `wsdl_headers` (*Object*): Set HTTP headers with values to be sent on WSDL requests.
- `wsdl_options` (*Object*): Set options for the request module on WSDL requests. If using the default request module, see [Request Config | Axios Docs](https://axios-http.com/docs/req_config).
- `disableCache` (*boolean*): Prevents caching WSDL files and option objects.
- `overridePromiseSuffix` (*string*): Override the default method name suffix of WSDL operations for Promise-based methods. If any WSDL operation name ends with `Async', you must use this option. (**Default:** `Async`)
- `normalizeNames` (*boolean*): Replace non-identifier characters (`[^a-z$_0-9]`) with `_` in WSDL operation names. Note: Clients using WSDLs with two operations like `soap:method` and `soap-method` will be overwritten. In this case, you must use bracket notation instead (`client['soap:method']()`).
- `namespaceArrayElements` (*boolean*): Support non-standard array semantics. JSON arrays of the form `{list: [{elem: 1}, {elem: 2}]}` will be marshalled into XML as `<list><elem>1</elem></list> <list><elem>2</elem></list>`. If `false`, it would be marshalled into `<list> <elem>1</elem> <elem>2</elem> </list>`. (**Default:** `true`)
- `stream` (*boolean*): Use streams to parse the XML SOAP responses. (**Default:** `false`)
- `returnSaxStream` (*boolean*): Return the SAX stream, transferring responsibility of parsing XML to the end user. Only valid when the *stream* option is set to `true`. (**Default:** `false`)
- `parseReponseAttachments` (*boolean*): Treat response as multipart/related response with MTOM attachment. Reach attachments on the `lastResponseAttachments` property of SoapClient. (**Default:** `false`)
- `callback` (*Function*):
- `err` (*Error* | *<AggregateError>*)
- `result` (*Any*)
- Returns: `Client`
#### Example
``` javascript

@@ -115,3 +134,4 @@ var soap = require('soap');

var args = {name: 'value'};
soap.createClient(url, function(err, client) {
soap.createClient(url, {}, function(err, client) {
client.MyFunction(args, function(err, result) {

@@ -122,6 +142,15 @@ console.log(result);

```
This client (WSDL files and specified options) has a built in WSDL cache. You can use the `disableCache` option to disable it.
Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.
### soap.createClientAsync(url[, options]) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.
Construct a `Promise<Client>` with the given WSDL file.
- `url` (*string*): A HTTP/HTTPS URL or a local filesystem path.
- `options` (*Object*): See [soap.createClient(url[, options], callback)](#soapcreateclienturl-options-callback---create-a-new-soap-client-from-a-wsdl-url-also-supports-a-local-filesystem-path) for a description.
- Returns: `Promise<Client>`
#### Example
``` javascript

@@ -131,2 +160,4 @@ var soap = require('soap');

var args = {name: 'value'};
// then/catch
soap.createClientAsync(url).then((client) => {

@@ -137,36 +168,36 @@ return client.MyFunctionAsync(args);

});
// async/await
var client = await soap.createClientAsync(url);
var result = await client.MyFunctionAsync(args);
console.log(result[0]);
```
This client (WSDL files and specified options) has a built in WSDL cache. You can use the `disableCache` option to disable it.
Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.
#### Options
### soap.listen(*server*, *path*, *services*, *wsdl*, *callback*) - create a new SOAP server that listens on *path* and provides *services*.
### soap.listen(*server*, *options*) - create a new SOAP server that listens on *path* and provides *services*.
The `options` argument allows you to customize the client with the following properties:
- `server` (*Object*): A [http](https://nodejs.org/api/http.html) server or [Express](http://expressjs.com/) framework based server.
- `path` (*string*)
- `options` (*Object*): An object containing *server options* and [WSDL Options](#handling-xml-attributes-value-and-xml-wsdloptions)
- `path` (*string*)
- `services` (*Object*)
- `xml` (*string*)
- `uri` (*string*)
- `pfx` (*string* | *Buffer*): The private key, certificate and CA certs of the server in PFX or PKCS12 format. (Mutually exclusive with the key, cert and ca options.)
- `key` (*string* | *Buffer*): The private key of the server in PEM format. (Could be an array of keys). (Required)
- `passphrase` (*string*): The passphrase for the private key or pfx.
- `cert` (*string* | *Buffer*): The certificate key of the server in PEM format. (Could be an array of certs). (Required)
- `ca` (*string[]* | *Buffer[]*): Trusted certificates in PEM format. If this is omitted several well known "root" CAs will be used, like VeriSign. These are used to authorize connections.
- `crl` (*string* | *string[]*: PEM encoded CRLs (Certificate Revocation List)
- `ciphers` (*string*): A description of the ciphers to use or exclude, separated by `:`. The default cipher suite is:
- `enableChunkedEncoding` (*boolean*): Controls chunked transfer encoding in response. Some clients (such as Windows 10's MDM enrollment SOAP client) are sensitive to transfer-encoding mode and can't accept chunked response. This option lets users disable chunked transfer encoding for such clients. (**Default:** `true`)
- `services` (*Object*)
- `wsdl` (*string*): An XML string that defines the service.
- `callback` (*Function*): A function to run after the server has been initialized.
- Returns: `Server`
- endpoint: to override the SOAP service's host specified in the `.wsdl` file.
- envelopeKey: to set specific key instead of `<pre><soap:Body></soap:Body></pre>`.
- preserveWhitespace: to preserve leading and trailing whitespace characters in text and cdata.
- escapeXML: escape special XML characters in SOAP message (e.g. `&`, `>`, `<` etc), default: `true`.
- suppressStack: suppress the full stack trace for error messages.
- returnFault: return an `Invalid XML` SOAP fault on a bad request, default: `false`.
- forceSoap12Headers: to set proper headers for SOAP v1.2.
- httpClient: to provide your own http client that implements `request(rurl, data, callback, exheaders, exoptions)`.
- request: to override the [request](https://github.com/request/request) module.
- wsdl_headers: custom HTTP headers to be sent on WSDL requests.
- wsdl_options: custom options for the request module on WSDL requests.
- disableCache: don't cache WSDL files and client options, request them every time.
- overridePromiseSuffix: if your wsdl operations contains names with Async suffix, you will need to override the default promise suffix to a custom one, default: `Async`.
- normalizeNames: if your wsdl operations contains names with non identifier characters (`[^a-z$_0-9]`), replace them with `_`. Note: if using this option, clients using wsdls with two operations like `soap:method` and `soap-method` will be overwritten. Then, use bracket notation instead (`client['soap:method']()`).
- namespaceArrayElements: provides support for nonstandard array semantics. If true, JSON arrays of the form `{list: [{elem: 1}, {elem: 2}]}` are marshalled into xml as `<list><elem>1</elem></list> <list><elem>2</elem></list>`. If false, marshalls into `<list> <elem>1</elem> <elem>2</elem> </list>`. Default: `true`.
- stream: allows using a stream to parse the XML SOAP response. Default: `false`
- returnSaxStream: enables the library to return the sax stream, transferring to the end user the responsibility of parsing the XML. It can be used only in combination with *stream* argument set to `true`. Default: `false`
- parseReponseAttachments: Treat response as multipart/related response with MTOM attachment. Reach attachments on the `lastResponseAttachments` property of SoapClient. Default: `false`
#### Example
Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.
### soap.listen(*server*, *path*, *services*, *wsdl*, *callback*) - create a new SOAP server that listens on *path* and provides *services*.
*server* can be a [http](https://nodejs.org/api/http.html) Server or [express](http://expressjs.com/) framework based server
*wsdl* is an xml string that defines the service.
*callback* a function to run after the server has been initialized.
``` javascript

@@ -244,16 +275,2 @@ var myService = {

### Options
You can pass in server and [WSDL Options](#handling-xml-attributes-value-and-xml-wsdloptions)
using an options hash.
Server options include the below:
- `pfx`: A string or Buffer containing the private key, certificate and CA certs of the server in PFX or PKCS12 format. (Mutually exclusive with the key, cert and ca options.)
- `key`: A string or Buffer containing the private key of the server in PEM format. (Could be an array of keys). (Required)
- `passphrase`: A string of passphrase for the private key or pfx.
- `cert`: A string or Buffer containing the certificate key of the server in PEM format. (Could be an array of certs). (Required)
- `ca`: An array of strings or Buffers of trusted certificates in PEM format. If this is omitted several well known "root" CAs will be used, like VeriSign. These are used to authorize connections.
- `crl` : Either a string or list of strings of PEM encoded CRLs (Certificate Revocation List)
- `ciphers`: A string describing the ciphers to use or exclude, separated by :. The default cipher suite is:
- `enableChunkedEncoding`: A boolean for controlling chunked transfer encoding in response. Some client (such as Windows 10's MDM enrollment SOAP client) is sensitive to transfer-encoding mode and can't accept chunked response. This option let user disable chunked transfer encoding for such a client. Default to `true` for backward compatibility.
``` javascript

@@ -277,4 +294,3 @@ var xml = require('fs').readFileSync('myservice.wsdl', 'utf8');

If the `log` method is defined it will be called with 'received' and 'replied'
along with data.
If the `log` method is defined, it will be called with 'received' and 'replied' along with the data.

@@ -507,20 +523,11 @@ ``` javascript

See [Security](#security) for example usage.
### Client.*method*(args, callback, options) - call *method* on the SOAP service.
``` javascript
client.MyFunction({name: 'value'}, function(err, result, rawResponse, soapHeader, rawRequest) {
// result is a javascript object
// rawResponse is the raw xml response string
// soapHeader is the response soap header as a javascript object
// rawRequest is the raw xml request string
})
```
The `args` argument allows you to supply arguments that generate an XML document inside of the SOAP Body section.
The `options` object is optional and is passed to the `request`-module.
Interesting properties might be:
* `timeout`: Timeout in milliseconds
* `forever`: Enables keep-alive connections and pools them
* `attachments`: array of attachment objects. This converts the request into MTOM: _headers['Content-Type']='multipart/related; type="application/xop+xml"; start= ... '_
- `args` (*Object*): Arguments that generate an XML document inside of the SOAP Body section.
- `callback` (*Function*)
- `options` (*Object*): Set options for the request module on WSDL requests. If using the default request module, see [Request Config | Axios Docs](https://axios-http.com/docs/req_config). Additional options supported by `node-soap` are documented below:
- `forever` (*boolean*): Enables keep-alive connections and pools them
- `attachments` (*Array*): array of attachment objects. This converts the request into MTOM: _headers['Content-Type']='multipart/related; type="application/xop+xml"; start= ... '_
```

@@ -536,7 +543,23 @@ [{

```
* `forceMTOM`: set to True if you want to send the request as MTOM even if you don't have attachments
- `forceMTOM` (*boolean*): Send the request as MTOM even if you don't have attachments.
- `forceGzip` (*boolean*): Force transfer-encoding in gzip. (**Default:** `false`)
#### Example
``` javascript
client.MyFunction({name: 'value'}, function(err, result, rawResponse, soapHeader, rawRequest) {
// result is a javascript object
// rawResponse is the raw xml response string
// soapHeader is the response soap header as a javascript object
// rawRequest is the raw xml request string
})
```
### Client.*method*Async(args, options) - call *method* on the SOAP service.
- `args` (*Object*): Arguments that generate an XML document inside of the SOAP Body section.
- `options` (*Object*): See [Client.*method*(args, callback, options) - call *method* on the SOAP service.](#clientmethodargs-callback-options---call-method-on-the-soap-service) for a description.
#### Example
``` javascript

@@ -552,21 +575,2 @@ client.MyFunctionAsync({name: 'value'}).then((result) => {

The `args` argument allows you to supply arguments that generate an XML document inside of the SOAP Body section.
The `options` object is optional and is passed to the `request`-module.
Interesting properties might be:
* `timeout`: Timeout in milliseconds
* `forever`: Enables keep-alive connections and pools them
* `attachments`: array of attachment objects. This converts the request into MTOM: _headers['Content-Type']='multipart/related; type="application/xop+xml"; start= ... '_
```
[{
mimetype: content mimetype,
contentId: part id,
name: file name,
body: binary data
},
...
]
```
* `forceMTOM`: set to True if you want to send the request as MTOM even if you don't have attachments
##### Example with JSON for the `args`

@@ -603,2 +607,9 @@ The example above uses `{name: 'value'}` as the args. This may generate a SOAP messages such as:

- `args` (*Object*): Arguments that generate an XML document inside of the SOAP Body section.
- `callback` (*Function*)
- `options` (*Object*): See [Client.*method*(args, callback, options) - call *method* on the SOAP service.](#clientmethodargs-callback-options---call-method-on-the-soap-service) for a description.
- `extraHeaders` (*Object*): Sets HTTP headers for the WSDL request.
#### Example
``` javascript

@@ -605,0 +616,0 @@ client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {

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