Permalink
Browse files

Merge pull request #103 from artembeloglazov/master

Added method for soapHeaders and lastRequest property
  • Loading branch information...
2 parents a8b8552 + 95ae39a commit bf6455aa56f66d53d7101d319234adde1840cbed @milewise milewise committed Oct 17, 2012
Showing with 24 additions and 0 deletions.
  1. +11 −0 Readme.md
  2. +13 −0 lib/client.js
View
@@ -144,6 +144,17 @@ An instance of Client is passed to the soap.createClient callback. It is used t
// result is a javascript object
})
```
+### Client.*addSoapHeader*(soapHeader[, name, namespace, xmlns]) - add soapHeader to soap:Header node
+#### Options
+
+ - `soapHeader` Object({rootName: {name: "value"}}) or strict xml-string
+
+##### Optional parameters when first arg is object :
+ - `name` Unknown parameter (it could just a empty string)
+ - `namespace` prefix of xml namespace
+ - `xmlns` URI
+
+### Client.*lastRequest* - the property that contains last full soap request for client logging
## WSSecurity
View
@@ -16,6 +16,16 @@ var Client = function(wsdl, endpoint) {
this._initializeServices(endpoint);
}
+Client.prototype.addSoapHeader = function(soapHeader, name, namespace, xmlns) {
+ if(!this.soapHeaders){
+ this.soapHeaders = [];
+ }
+ if(typeof soapHeader == 'object'){
+ soapHeader = this.wsdl.objectToXML(soapHeader, name, namespace, xmlns);
+ }
+ this.soapHeaders.push(soapHeader);
+}
+
Client.prototype.setEndpoint = function(endpoint) {
this.endpoint = endpoint;
this._initializeServices(endpoint);
@@ -117,13 +127,16 @@ Client.prototype._invoke = function(method, arguments, location, callback) {
encoding +
this.wsdl.xmlnsInEnvelope + '>' +
"<soap:Header>" +
+ (self.soapHeaders ? self.soapHeaders.join("\n") : "") +
(self.security ? self.security.toXML() : "") +
"</soap:Header>" +
"<soap:Body>" +
message +
"</soap:Body>" +
"</soap:Envelope>";
+ self.lastRequest = xml;
+
http.request(location, xml, function(err, response, body) {
if (err) {
callback(err);

0 comments on commit bf6455a

Please sign in to comment.