Comparing version 0.13.0 to 0.14.0
@@ -0,0 +0,0 @@ #Contribution Guidelines |
@@ -0,1 +1,15 @@ | ||
0.14.0 / 2016-04-12 | ||
================= | ||
* [ENHANCEMENT] Allow to call methods with `callback` as last param in order to align with node.js `callback last` pattern (#814) | ||
* [ENHANCEMENT] Re-enabled `ignoreBaseNameSpaces` option (#809) | ||
* [FIX] Avoid overwriting request headers with options in client method invocation (#813) | ||
* [ENHANCEMENT] Accept `time` value in in `extraHeaders` options in order to retrieve the `lastElapsedTime` for the response (#811) | ||
* [ENHANCEMENT] Allow to set a custom envelope key for the SOAP request (#812) | ||
* [FIX] Removed double declaration of `WSDL` variable in `lib/soap.js` (#810) | ||
* [DOC] Added documentation for `wsdl_options` and `wsdl_headers` options in `createClient()` method (#806) | ||
* [ENHANCEMENT] Added support to override the namespace definition of the root element (#805) | ||
* [ENHANCEMENT] Ignore "whitespace only" differences in `request/response sample tests` in order to make differences easier to spot (#804) | ||
* [ENHANCEMENT] Added support for WSSecurity XML signing with x509 certificats. Dropped support for node.js < 0.10.x (#801) | ||
* [ENHANCEMENT] Remove assertions/checkin of certificates in `ClientSSLSecurity` (#800) | ||
0.13.0 / 2016-02-16 | ||
@@ -2,0 +16,0 @@ ================= |
"use strict"; | ||
module.exports = require('./lib/soap'); |
@@ -123,2 +123,3 @@ /* | ||
this.wsdl.options.attributesKey = options.attributesKey || 'attributes'; | ||
this.wsdl.options.envelopeKey = options.envelopeKey || 'soap'; | ||
this.wsdl.options.forceSoap12Headers = !!options.forceSoap12Headers; | ||
@@ -150,2 +151,3 @@ }; | ||
var self = this; | ||
var temp; | ||
return function(args, callback, options, extraHeaders) { | ||
@@ -155,2 +157,11 @@ if (typeof args === 'function') { | ||
args = {}; | ||
} else if (typeof options === 'function') { | ||
temp = callback; | ||
callback = options; | ||
options = temp; | ||
} else if (typeof extraHeaders === 'function') { | ||
temp = callback; | ||
callback = extraHeaders; | ||
extraHeaders = options; | ||
options = temp; | ||
} | ||
@@ -170,2 +181,3 @@ self._invoke(method, args, location, function(error, result, raw, soapHeader) { | ||
defs = this.wsdl.definitions, | ||
envelopeKey = this.wsdl.options.envelopeKey, | ||
ns = defs.$targetNamespace, | ||
@@ -181,7 +193,7 @@ encoding = '', | ||
}, | ||
xmlnsSoap = "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""; | ||
xmlnsSoap = "xmlns:" + envelopeKey + "=\"http://schemas.xmlsoap.org/soap/envelope/\""; | ||
if (this.wsdl.options.forceSoap12Headers) { | ||
headers["Content-Type"] = "application/soap+xml; charset=utf-8"; | ||
xmlnsSoap = "xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\""; | ||
xmlnsSoap = "xmlns:" + envelopeKey + "=\"http://www.w3.org/2003/05/soap-envelope\""; | ||
} | ||
@@ -225,3 +237,3 @@ | ||
xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + | ||
"<soap:Envelope " + | ||
"<" + envelopeKey + ":Envelope " + | ||
xmlnsSoap + " " + | ||
@@ -233,6 +245,6 @@ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + | ||
( | ||
"<soap:Header>" + | ||
"<" + envelopeKey + ":Header>" + | ||
(self.soapHeaders ? self.soapHeaders.join("\n") : "") + | ||
(self.security ? self.security.toXML() : "") + | ||
"</soap:Header>" | ||
(self.security && !self.security.postProcess ? self.security.toXML() : "") + | ||
"</" + envelopeKey + ":Header>" | ||
) | ||
@@ -242,9 +254,14 @@ : | ||
) + | ||
"<soap:Body" + | ||
"<" + envelopeKey + ":Body" + | ||
(self.bodyAttributes ? self.bodyAttributes.join(' ') : '') + | ||
(self.security && self.security.postProcess ? " Id='_0'" : '') + | ||
">" + | ||
message + | ||
"</soap:Body>" + | ||
"</soap:Envelope>"; | ||
"</" + envelopeKey + ":Body>" + | ||
"</" + envelopeKey + ":Envelope>"; | ||
if(self.security && self.security.postProcess){ | ||
xml = self.security.postProcess(xml); | ||
} | ||
self.lastMessage = message; | ||
@@ -271,2 +288,3 @@ self.lastRequest = xml; | ||
self.lastResponseHeaders = response && response.headers; | ||
self.lastElapsedTime = response && response.elapsedTime; | ||
self.emit('response', body); | ||
@@ -273,0 +291,0 @@ |
@@ -50,2 +50,4 @@ /* | ||
var attr; | ||
var header; | ||
var mergeOptions = ['headers']; | ||
@@ -75,3 +77,9 @@ if (typeof data === 'string') { | ||
for (attr in exoptions) { | ||
options[attr] = exoptions[attr]; | ||
if (mergeOptions.indexOf(attr) !== -1) { | ||
for (header in exoptions[attr]) { | ||
options[attr][header] = exoptions[attr][header]; | ||
} | ||
} else { | ||
options[attr] = exoptions[attr]; | ||
} | ||
} | ||
@@ -78,0 +86,0 @@ debug('Http request: %j', options); |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -26,6 +26,2 @@ 'use strict'; | ||
} | ||
if(this.key.toString().lastIndexOf('-----BEGIN RSA PRIVATE KEY-----', 0) !== 0) { | ||
throw new Error('key should start with -----BEGIN RSA PRIVATE KEY-----'); | ||
} | ||
} | ||
@@ -41,6 +37,2 @@ | ||
} | ||
if(this.cert.toString().lastIndexOf('-----BEGIN CERTIFICATE-----', 0) !== 0) { | ||
throw new Error('cert should start with -----BEGIN CERTIFICATE-----'); | ||
} | ||
} | ||
@@ -57,6 +49,2 @@ | ||
} | ||
if(this.ca && this.ca.toString().lastIndexOf('-----BEGIN CERTIFICATE-----', 0) !== 0) { | ||
throw new Error('ca should start with -----BEGIN CERTIFICATE-----'); | ||
} | ||
} | ||
@@ -63,0 +51,0 @@ |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -9,2 +9,3 @@ "use strict"; | ||
, BearerSecurity: require('./BearerSecurity') | ||
, WSSecurityCert: require('./WSSecurityCert') | ||
}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /* |
@@ -16,3 +16,2 @@ /* | ||
var WSDL = require('./wsdl').WSDL; | ||
var _wsdlCache = {}; | ||
@@ -73,2 +72,3 @@ | ||
exports.WSSecurity = security.WSSecurity; | ||
exports.WSSecurityCert = security.WSSecurityCert; | ||
exports.ClientSSLSecurity = security.ClientSSLSecurity; | ||
@@ -75,0 +75,0 @@ exports.ClientSSLSecurityPFX = security.ClientSSLSecurityPFX; |
@@ -0,0 +0,0 @@ |
{ | ||
"name": "soap", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "A minimal node SOAP client", | ||
"engines": { | ||
"node": ">=0.8.0" | ||
"node": ">=0.10.0" | ||
}, | ||
@@ -15,3 +15,7 @@ "author": "Vinay Pulim <v@pulim.com>", | ||
"selectn": "^0.9.6", | ||
"strip-bom": "~0.3.1" | ||
"strip-bom": "~0.3.1", | ||
"ursa": "0.8.5 || >=0.9.3", | ||
"node-uuid": "~1.4.3", | ||
"ejs": "~2.3.4", | ||
"xml-crypto": "~0.8.0" | ||
}, | ||
@@ -37,3 +41,5 @@ "repository": { | ||
"devDependencies": { | ||
"colors": "^1.1.2", | ||
"coveralls": "^2.11.6", | ||
"diff": "^2.2.1", | ||
"duplexer": "~0.1.1", | ||
@@ -40,0 +46,0 @@ "glob": "~3.2.8", |
@@ -0,0 +0,0 @@ Publishing |
@@ -54,2 +54,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] | ||
- forceSoap12Headers: to set proper headers for SOAP v1.2 | ||
- envelopeKey: to set specific key instead of <pre><<b>soap</b>:Body></<b>soap</b>:Body></pre> | ||
- wsdl_options: custom options for the request module on WSDL requests. | ||
- wsdl_headers: custom HTTP headers to be sent on WSDL requests. | ||
@@ -325,2 +328,12 @@ ### soap.listen(*server*, *path*, *services*, *wsdl*) - create a new SOAP server that listens on *path* and provides *services*. | ||
####WSSecurity with X509 Certificate | ||
``` javascript | ||
var privateKey = fs.readFileSync(privateKeyPath); | ||
var publicKey = fs.readFileSync(publicKeyPath); | ||
var password = ''; // optional password | ||
var wsSecurity = new soap.WSSecurityCert(privateKey, publicKey, password, 'utf8'); | ||
client.setSecurity(wsSecurity); | ||
``` | ||
####BearerSecurity | ||
@@ -341,3 +354,3 @@ | ||
``` | ||
### Client.*service*.*port*.*method*(args, callback[, options]) - call a *method* using a specific *service* and *port* | ||
### Client.*service*.*port*.*method*(args, callback[, options[, extraHeaders]]) - call a *method* using a specific *service* and *port* | ||
@@ -349,2 +362,37 @@ ``` javascript | ||
``` | ||
#### Options (optional) | ||
- Accepts any option that the request module accepts, see [here.](https://github.com/mikeal/request) | ||
- For example, you could set a timeout of 5 seconds on the request like this: | ||
``` javascript | ||
client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) { | ||
// result is a javascript object | ||
}, {timeout: 5000}) | ||
``` | ||
- You can measure the elapsed time on the request by passing the time option: | ||
``` javascript | ||
client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) { | ||
// client.lastElapsedTime - the elapsed time of the last request in milliseconds | ||
}, {time: true}) | ||
``` | ||
#### Extra Headers (optional) | ||
Object properties define extra HTTP headers to be sent on the request. | ||
#### Alternative method call using callback-last pattern | ||
To align method call signature with node' standard callback-last patter and event allow promisification of method calls, the following method signatures are also supported: | ||
```javascript | ||
client.MyService.MyPort.MyFunction({name: 'value'}, options, function (err, result) { | ||
// result is a javascript object | ||
}) | ||
client.MyService.MyPort.MyFunction({name: 'value'}, options, extraHeaders, function (err, result) { | ||
// result is a javascript object | ||
}) | ||
``` | ||
###Overriding the namespace prefix | ||
@@ -367,11 +415,2 @@ `node-soap` is still working out some kinks regarding namespaces. If you find that an element is given the wrong namespace prefix in the request body, you can add the prefix to it's name in the containing object. I.E.: | ||
#### Options (optional) | ||
- Accepts any option that the request module accepts, see [here.](https://github.com/mikeal/request) | ||
- For example, you could set a timeout of 5 seconds on the request like this: | ||
``` javascript | ||
client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) { | ||
// result is a javascript object | ||
}, {timeout: 5000}) | ||
``` | ||
### Client.*lastRequest* - the property that contains last full soap request for client logging | ||
@@ -506,3 +545,24 @@ | ||
``` | ||
### Specifying the exact namespace definition of the root element | ||
In rare cases, you may want to precisely control the namespace definition that is included in the root element. | ||
You can specify the namespace definitions by setting the overrideRootElement key in the `wsdlOptions` like so: | ||
```javascript | ||
var wsdlOptions = { | ||
"overrideRootElement": { | ||
"namespace": "xmlns:tns", | ||
"xmlnsAttributes": [{ | ||
"name": "xmlns:ns2", | ||
"value": "http://tempuri.org/" | ||
}, { | ||
"name": "xmlns:ns3", | ||
"value": "http://sillypets.com/xsd" | ||
}] | ||
} | ||
}; | ||
``` | ||
To see it in practice, consider the sample files in: [test/request-response-samples/addPets__force_namespaces](https://github.com/vpulim/node-soap/tree/master/test/request-response-samples/addPets__force_namespaces) | ||
## Handling "ignored" namespaces | ||
@@ -509,0 +569,0 @@ If an Element in a `schema` definition depends on an Element which is present in the same namespace, normally the `tns:` |
@@ -0,0 +0,0 @@ var _ = require('lodash'); |
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 too big to display
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
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
159696
28
3313
692
10
12
4
+ Addedejs@~2.3.4
+ Addednode-uuid@~1.4.3
+ Addedursa@0.8.5 || >=0.9.3
+ Addedxml-crypto@~0.8.0
+ Addedejs@2.3.4(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedxml-crypto@0.8.5(transitive)
+ Addedxpath.js@1.1.0(transitive)