Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

soap-extended

adamkac628MIT0.25.0TypeScript support: included

A minimal node SOAP client

soap

readme

Soap NPM version Downloads Build Status Coveralls Status Gitter chat

A SOAP client and server for node.js.

This module lets you connect to web services using SOAP. It also provides a server that allows you to run your own SOAP services.

Features:

  • Very simple API
  • Handles both RPC and Document schema types
  • Supports multiRef SOAP messages (thanks to @kaven276)
  • Support for both synchronous and asynchronous method handlers
  • WS-Security (currently only UsernameToken and PasswordText encoding is supported)
  • Supports express based web server(body parser middleware can be used)

Install

Install with npm:

  npm install soap

Why can't I file an issue?

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.

Where can I find help?

Community support can be found on gitter:

Gitter chat

If you're looking for professional help you can contact the maintainers through this google form.

Module

soap.createClient(url[, options], callback) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.

  var soap = require('soap');
  var url = 'http://example.com/wsdl?wsdl';
  var args = {name: 'value'};
  soap.createClient(url, function(err, client) {
      client.MyFunction(args, function(err, result) {
          console.log(result);
      });
  });

This client has a built in WSDL cache. You can use the disableCache option to disable it.

soap.createClientAsync(url[, options]) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.

  var soap = require('soap');
  var url = 'http://example.com/wsdl?wsdl';
  var args = {name: 'value'};
  soap.createClientAsync(url).then((client) => {
    return client.MyFunctionAsync(args);
  }).then((result) => {
    console.log(result);
  });

This client has a built in WSDL cache. You can use the disableCache option to disable it.

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.
  • 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 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, 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.

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) - create a new SOAP server that listens on path and provides services.

server can be a http Server or express framework based server wsdl is an xml string that defines the service.

  var myService = {
      MyService: {
          MyPort: {
              MyFunction: function(args) {
                  return {
                      name: args.name
                  };
              },

              // This is how to define an asynchronous function.
              MyAsyncFunction: function(args, callback) {
                  // do some work
                  callback({
                      name: args.name
                  });
              },

              // This is how to receive incoming headers
              HeadersAwareFunction: function(args, cb, headers) {
                  return {
                      name: headers.Token
                  };
              },

              // You can also inspect the original `req`
              reallyDetailedFunction: function(args, cb, headers, req) {
                  console.log('SOAP `reallyDetailedFunction` request from ' + req.connection.remoteAddress);
                  return {
                      name: headers.Token
                  };
              }
          }
      }
  };

  var xml = require('fs').readFileSync('myservice.wsdl', 'utf8');

  //http server example
  var server = http.createServer(function(request,response) {
      response.end('404: Not Found: ' + request.url);
  });

  server.listen(8000);
  soap.listen(server, '/wsdl', myService, xml);

  //express server example
  var app = express();
  //body parser middleware are supported (optional)
  app.use(bodyParser.raw({type: function(){return true;}, limit: '5mb'}));
  app.listen(8001, function(){
      //Note: /wsdl route will be handled by soap module
      //and all other routes & middleware will continue to work
      soap.listen(app, '/wsdl', myService, xml);
  });

Options

You can pass in server and WSDL Options 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:
var xml = require('fs').readFileSync('myservice.wsdl', 'utf8');

soap.listen(server, {
    // Server options.
    path: '/wsdl',
    services: myService,
    xml: xml,

    // WSDL options.
    attributesKey: 'theAttrs',
    valueKey: 'theVal',
    xmlKey: 'theXml'
});

Server Logging

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

  server = soap.listen(...)
  server.log = function(type, data) {
    // type is 'received' or 'replied'
  };

Server Events

Server instances emit the following events:

  • request - Emitted for every received messages. The signature of the callback is function(request, methodName).
  • headers - Emitted when the SOAP Headers are not empty. The signature of the callback is function(headers, methodName).

The sequence order of the calls is request, headers and then the dedicated service method.

Server Response on one-way calls

The so called one-way (or asynchronous) calls occur when an operation is called with no output defined in WSDL. The server sends a response (defaults to status code 200 with no body) to the client disregarding the result of the operation.

You can configure the response to match the appropriate client expectation to the SOAP standard implementation. Pass in oneWay object in server options. Use the following keys: emptyBody: if true, returns an empty body, otherwise no content at all (default is false) responseCode: default statusCode is 200, override it with this options (for example 202 for SAP standard compliant response)

SOAP Fault

A service method can reply with a SOAP Fault to a client by throwing an object with a Fault property.

  throw {
    Fault: {
      Code: {
        Value: 'soap:Sender',
        Subcode: { value: 'rpc:BadArguments' }
      },
      Reason: { Text: 'Processing Error' }
    }
  };

To change the HTTP statusCode of the response include it on the fault. The statusCode property will not be put on the xml message.

  throw {
    Fault: {
      Code: {
        Value: 'soap:Sender',
        Subcode: { value: 'rpc:BadArguments' }
      },
      Reason: { Text: 'Processing Error' },
      statusCode: 500
    }
  };

Server security example using PasswordDigest

If server.authenticate is not defined then no authentication will take place.

Asynchronous authentication:

  server = soap.listen(...)
  server.authenticate = function(security, callback) {
    var created, nonce, password, user, token;
    token = security.UsernameToken, user = token.Username,
            password = token.Password, nonce = token.Nonce, created = token.Created;

    myDatabase.getUser(user, function (err, dbUser) {
      if (err || !dbUser) {
        callback(false);
        return;
      }

      callback(password === soap.passwordDigest(nonce, created, dbUser.password));
    });
  };

Synchronous authentication:

  server = soap.listen(...)
  server.authenticate = function(security) {
    var created, nonce, password, user, token;
    token = security.UsernameToken, user = token.Username,
            password = token.Password, nonce = token.Nonce, created = token.Created;
    return user === 'user' && password === soap.passwordDigest(nonce, created, 'password');
  };

Server connection authorization

The server.authorizeConnection method is called prior to the soap service method. If the method is defined and returns false then the incoming connection is terminated.

  server = soap.listen(...)
  server.authorizeConnection = function(req) {
    return true; // or false
  };

SOAP Headers

Received SOAP Headers

A service method can look at the SOAP headers by providing a 3rd arguments.

  {
      HeadersAwareFunction: function(args, cb, headers) {
          return {
              name: headers.Token
          };
      }
  }

It is also possible to subscribe to the 'headers' event. The event is triggered before the service method is called, and only when the SOAP Headers are not empty.

  server = soap.listen(...)
  server.on('headers', function(headers, methodName) {
    // It is possible to change the value of the headers
    // before they are handed to the service method.
    // It is also possible to throw a SOAP Fault
  });

First parameter is the Headers object; second parameter is the name of the SOAP method that will called (in case you need to handle the headers differently based on the method).

Outgoing SOAP Headers

Both client & server can define SOAP headers that will be added to what they send. They provide the following methods to manage the headers.

addSoapHeader(soapHeader[, name, namespace, xmlns]) - add soapHeader to soap:Header node

Parameters
  • soapHeader Object({rootName: {name: 'value'}}), strict xml-string,
                 or function (server only)

For servers only, soapHeader can be a function, which allows headers to be dynamically generated from information in the request. This function will be called with the following arguments for each received request:

  • methodName The name of the request method
  • args The arguments of the request
  • headers The headers in the request
  • req The original request object

The return value of the function must be an Object({rootName: {name: 'value'}}) or strict xml-string, which will be inserted as an outgoing header of the response to that request.

For example:

  server = soap.listen(...);
  server.addSoapHeader(function(methodName, args, headers, req) {
    console.log('Adding headers for method', methodName);
    return {
      MyHeader1: args.SomeValueFromArgs,
      MyHeader2: headers.SomeRequestHeader
    };
    // or you can return "<MyHeader1>SomeValue</MyHeader1>"
  });
Returns

The index where the header is inserted.

Optional parameters when first arg is object :
  • name Unknown parameter (it could just a empty string)
  • namespace prefix of xml namespace
  • xmlns URI

changeSoapHeader(index, soapHeader[, name, namespace, xmlns]) - change an already existing soapHeader

Parameters
  • index index of the header to replace with provided new value
  • soapHeader Object({rootName: {name: 'value'}}), strict xml-string
                 or function (server only)

See addSoapHeader for how to pass a function into soapHeader.

getSoapHeaders() - return all defined headers

clearSoapHeaders() - remove all defined headers

Client

An instance of Client is passed to the soap.createClient callback. It is used to execute methods on the soap service.

Client.describe() - description of services, ports and methods as a JavaScript object

  client.describe() // returns
    {
      MyService: {
        MyPort: {
          MyFunction: {
            input: {
              name: 'string'
            }
          }
        }
      }
    }

Client.setSecurity(security) - use the specified security protocol

Client.method(args, callback, options) - call method on the SOAP service.

  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

Client.methodAsync(args) - call method on the SOAP service.

  client.MyFunctionAsync({name: 'value'}).then((result) => {
    // result is a javascript array containing result, rawResponse, soapheader, and 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.

Example with JSON for the args

The example above uses {name: 'value'} as the args. This may generate a SOAP messages such as:

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <Request xmlns="http://www.example.com/v1">
          <name>value</name>
      </Request>
   </soapenv:Body>
</soapenv:Envelope>

Note that the "Request" element in the output above comes from the WSDL. If an element in args contains no namespace prefix, the default namespace is assumed. Otherwise, you must add the namespace prefixes to the element names as necessary (e.g., ns1:name).

Currently, when supplying JSON args, elements may not contain both child elements and a text value, even though that is allowed in the XML specification.

Example with XML String for the args

You may pass in a fully-formed XML string instead the individual elements in JSON args and attributes that make up the XML. The XML string should not contain an XML declaration (e.g., <?xml version="1.0" encoding="UTF-8"?>) or a document type declaration (e.g., <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">).

 var args = { _xml: "<ns1:MyRootElement xmlns:ns1="http://www.example.com/v1/ns1">
                        <ChildElement>elementvalue</ChildElement>
                     </ns1:MyRootElement>"
            };

You must specify all of the namespaces and namespace prefixes yourself. The element(s) from the WSDL are not utilized as they were in the "Example with JSON as the args" example above, which automatically populated the "Request" element.

Client.service.port.method(args, callback[, options[, extraHeaders]]) - call a method using a specific service and port

  client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
      // result is a javascript object
  })

Options (optional)

  • Accepts any option that the request module accepts, see here.
  • For example, you could set a timeout of 5 seconds on the request like this:
    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:

    client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
        // client.lastElapsedTime - the elapsed time of the last request in milliseconds
    }, {time: true})
  • Also, you could pass your soap request through a debugging proxy such as Fiddler or Betwixt.

    client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
        // client.lastElapsedTime - the elapsed time of the last request in milliseconds
    }, {proxy: 'http://localhost:8888'})
  • You can modify xml (string) before call:

     client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
         // client.lastElapsedTime - the elapsed time of the last request in milliseconds
     }, {postProcess: function(_xml) {
       return _xml.replace('text', 'newtext');
     }})

Extra Headers (optional)

Object properties define extra HTTP headers to be sent on the request.

  • Add custom User-Agent:
    client.addHttpHeader('User-Agent', `CustomUserAgent`);

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:

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

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.:

  client.MyService.MyPort.MyFunction({'ns1:name': 'value'}, function(err, result) {
      // request body sent with `<ns1:name`, regardless of what the namespace should have been.
  }, {timeout: 5000})
  • Remove namespace prefix of param
  client.MyService.MyPort.MyFunction({':name': 'value'}, function(err, result) {
      // request body sent with `<name`, regardless of what the namespace should have been.
  }, {timeout: 5000})

Client.lastRequest - the property that contains last full soap request for client logging

Client.setEndpoint(url) - overwrite the SOAP service endpoint address

Client Events

Client instances emit the following events:

request

Emitted before a request is sent. The event handler has the signature (xml, eid).

  • xml - The entire Soap request (Envelope) including headers.
  • eid - The exchange id.

message

Emitted before a request is sent, but only the body is passed to the event handler. Useful if you don't want to log /store Soap headers. The event handler has the signature (message, eid).

  • message - Soap body contents.
  • eid - The exchange id.

soapError

Emitted when an erroneous response is received. Useful if you want to globally log errors. The event handler has the signature (error, eid).

  • error - An error object which also contains the resoponse.
  • eid - The exchange id.

    response

    Emitted after a response is received. This is emitted for all responses (both success and errors). The event handler has the signature (body, response, eid)

  • body - The SOAP response body.

  • response - The entire IncomingMessage response object.
  • eid - The exchange id.

An 'exchange' is a request/response couple. Event handlers receive the exchange id in all events. The exchange id is the same for the requests events and the responses events, this way you can use it to retrieve the matching request when an response event is received.

By default exchange ids are generated by using node-uuid but you can use options in client calls to pass your own exchange id.

Example :

  client.MyService.MyPort.MyFunction(args , function(err, result) {

  }, {exchangeId: myExchangeId})

Security

node-soap has several default security protocols. You can easily add your own as well. The interface is quite simple. Each protocol defines these optional methods:

  • addOptions(options) - a method that accepts an options arg that is eventually passed directly to request.
  • addHeaders(headers) - a method that accepts an argument with HTTP headers, to add new ones.
  • toXML() - a method that returns a string of XML to be appended to the SOAP headers. Not executed if postProcess is also defined.
  • postProcess(xml, envelopeKey) - a method that receives the the assembled request XML plus envelope key, and returns a processed string of XML. Executed before options.postProcess.

BasicAuthSecurity

  client.setSecurity(new soap.BasicAuthSecurity('username', 'password'));

BearerSecurity

  client.setSecurity(new soap.BearerSecurity('token'));

ClientSSLSecurity

Note: If you run into issues using this protocol, consider passing these options as default request options to the constructor:

  • rejectUnauthorized: false
  • strictSSL: false
  • secureOptions: constants.SSL_OP_NO_TLSv1_2 (this is likely needed for node >= 10.0)

If you want to reuse tls sessions, you can use the option forever: true.

client.setSecurity(new soap.ClientSSLSecurity(
                '/path/to/key',
                'path/to/cert',
                '/path/to/ca-cert',  /*or an array of buffer: [fs.readFileSync('/path/to/ca-cert/1', 'utf8'),
                'fs.readFileSync('/path/to/ca-cert/2', 'utf8')], */
                {   /*default request options like */
                    // strictSSL: true,
                    // rejectUnauthorized: false,
                    // hostname: 'some-hostname'
                    // secureOptions: constants.SSL_OP_NO_TLSv1_2,
                    // forever: true,
                },
      ));

ClientSSLSecurityPFX

Note: If you run into issues using this protocol, consider passing these options as default request options to the constructor:

  • rejectUnauthorized: false
  • strictSSL: false
  • secureOptions: constants.SSL_OP_NO_TLSv1_2 (this is likely needed for node >= 10.0)

If you want to reuse tls sessions, you can use the option forever: true.

client.setSecurity(new soap.ClientSSLSecurityPFX(
                '/path/to/pfx/cert', // or a buffer: [fs.readFileSync('/path/to/pfx/cert', 'utf8'),
                'path/to/optional/passphrase',
                {   /*default request options like */
                    // strictSSL: true,
                    // rejectUnauthorized: false,
                    // hostname: 'some-hostname'
                    // secureOptions: constants.SSL_OP_NO_TLSv1_2,
                    // forever: true,
                },
      ));

WSSecurity

WSSecurity implements WS-Security. UsernameToken and PasswordText/PasswordDigest is supported.

  var options = {
    hasNonce: true,
    actor: 'actor'
  };
  var wsSecurity = new soap.WSSecurity('username', 'password', options)
  client.setSecurity(wsSecurity);

the options object is optional and can contain the following properties:

  • passwordType: 'PasswordDigest' or 'PasswordText' (default: 'PasswordText')
  • hasTimeStamp: adds Timestamp element (default: true)
  • hasTokenCreated: adds Created element (default: true)
  • hasNonce: adds Nonce element (default: false)
  • mustUnderstand: adds mustUnderstand=1 attribute to security tag (default: false)
  • actor: if set, adds Actor attribute with given value to security tag (default: '')

WSSecurityCert

WS-Security X509 Certificate support.

  var privateKey = fs.readFileSync(privateKeyPath);
  var publicKey = fs.readFileSync(publicKeyPath);
  var password = ''; // optional password
  var wsSecurity = new soap.WSSecurityCert(privateKey, publicKey, password);
  client.setSecurity(wsSecurity);

NTLMSecurity

Parameter invocation:

  client.setSecurity(new soap.NTLMSecurity('username', 'password', 'domain', 'workstation'));

This can also be set up with a JSON object, substituting values as appropriate, for example:

  var loginData = {username: 'username', password: 'password', domain: 'domain', workstation: 'workstation'};
  client.setSecurity(new soap.NTLMSecurity(loginData));

Handling XML Attributes, Value and XML (wsdlOptions).

Sometimes it is necessary to override the default behaviour of node-soap in order to deal with the special requirements of your code base or a third library you use. Therefore you can use the wsdlOptions Object, which is passed in the #createClient() method and could have any (or all) of the following contents:

var wsdlOptions = {
  attributesKey: 'theAttrs',
  valueKey: 'theVal',
  xmlKey: 'theXml'
}

If nothing (or an empty Object {}) is passed to the #createClient() method, the node-soap defaults (attributesKey: 'attributes', valueKey: '$value' and xmlKey: '$xml') are used.

Overriding the value key

By default, node-soap uses $value as the key for any parsed XML value which may interfere with your other code as it could be some reserved word, or the $ in general cannot be used for a key to start with.

You can define your own valueKey by passing it in the wsdl_options to the createClient call:

var wsdlOptions = {
  valueKey: 'theVal'
};

soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, function (err, client) {
  // your code
});

Overriding the xml key

By default, node-soap uses $xml as the key to pass through an XML string as is; without parsing or namespacing it. It overrides all the other content that the node might have otherwise had.

For example :

{
  dom: {
    nodeone: {
      $xml: '<parentnode type="type"><childnode></childnode></parentnode>',
      siblingnode: 'Cant see me.'
    },
    nodetwo: {
      parentnode: {
        attributes: {
          type: 'type'
        },
        childnode: ''
      }
    }
  }
};

could become

<tns:dom>
  <tns:nodeone>
    <parentnode type="type">
      <childnode></childnode>
    </parentnode>
  </tns:nodeone>
  <tns:nodetwo>
    <tns:parentnode type="type">
      <tns:childnode></tns:childnode>
    </tns:parent>
  </tns:nodetwo>
</tns:dom>

You can define your own xmlKey by passing it in the wsdl_options object to the createClient call:

var wsdlOptions = {
  xmlKey: 'theXml'
};

soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, function (err, client) {
  // your code
});

Overriding the attributes key

By default, node-soap uses attributes as the key to define a nodes attributes.

{
  parentnode: {
    childnode: {
      attributes: {
        name: 'childsname'
      },
      $value: 'Value'
    }
  }
}

could become

<parentnode>
  <childnode name="childsname">Value</childnode>
</parentnode>

However, attributes may be a reserved key for some systems that actually want a node called attributes

<attributes>
</attributes>

You can define your own attributesKey by passing it in the wsdl_options object to the createClient call:

var wsdlOptions = {
  attributesKey: '$attributes'
};

soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, function (err, client) {
  client.method({
    parentnode: {
      childnode: {
        $attributes: {
          name: 'childsname'
        },
        $value: 'Value'
      }
    }
  });
});

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:

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, have a look at the sample files in: test/request-response-samples/addPets__force_namespaces

Custom Deserializer

Sometimes it's useful to handle deserialization in your code instead of letting node-soap do it. For example if the soap response contains dates that are not in a format recognized by javascript, you might want to use your own function to handle them.

To do so, you can pass a customDeserializer object in options. The properties of this object are the types that your deserializer handles itself.

Example :


   var wsdlOptions = {
     customDeserializer: {

       // this function will be used to any date found in soap responses
       date: function (text, context) {
         /* text is the value of the xml element.
           context contains the name of the xml element and other infos :
             {
                 name: 'lastUpdatedDate',
                 object: {},
                 schema: 'xsd:date',
                 id: undefined,
                 nil: false
             }

          */
         return text;
       }
     }
   };

   soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, function (err, client) {
     ...
   });

Changing the tag formats to use self-closing (empty element) tags

The XML specification specifies that there is no semantic difference between <Tag></Tag> and <Tag />, and node-soap defaults to using the <Tag></Tag> format. But if your web service is particular, or if there is a stylistic preference, the useEmptyTag option causes tags with no contents to use the <Tag /> format instead.

var wsdlOptions = {
  useEmptyTag: true
};

For example: { MyTag: { attributes: { MyAttr: 'value' } } } is:

  • Without useEmptyTag: <MyTag MyAttr="value"></MyTag>
  • With useEmptyTag set to true: <MyTag MyAttr="value" />

Handling "ignored" namespaces

If an Element in a schema definition depends on an Element which is present in the same namespace, normally the tns: namespace prefix is used to identify this Element. This is not much of a problem as long as you have just one schema defined (inline or in a separate file). If there are more schema files, the tns: in the generated soap file resolved mostly to the parent wsdl file, which was obviously wrong.

node-soap now handles namespace prefixes which shouldn't be resolved (because it's not necessary) as so called ignoredNamespaces which default to an Array of 3 Strings (['tns', 'targetNamespace', 'typedNamespace']).

If this is not sufficient for your purpose you can easily add more namespace prefixes to this Array, or override it in its entirety by passing an ignoredNamespaces object within the options you pass in soap.createClient() method.

A simple ignoredNamespaces object, which only adds certain namespaces could look like this:

 var options = {
   ignoredNamespaces: {
     namespaces: ['namespaceToIgnore', 'someOtherNamespace']
   }
 }

This would extend the ignoredNamespaces of the WSDL processor to ['tns', 'targetNamespace', 'typedNamespace', 'namespaceToIgnore', 'someOtherNamespace'].

If you want to override the default ignored namespaces you would simply pass the following ignoredNamespaces object within the options:

 var options = {
     ignoredNamespaces: {
       namespaces: ['namespaceToIgnore', 'someOtherNamespace'],
       override: true
     }
   }

This would override the default ignoredNamespaces of the WSDL processor to ['namespaceToIgnore', 'someOtherNamespace']. (This shouldn't be necessary, anyways).

If you want to override the default ignored namespaces you would simply pass the following ignoredNamespaces object within the options:

 var options = {
     ignoredNamespaces: {
       namespaces: ['namespaceToIgnore', 'someOtherNamespace'],
       override: true
     }
   }

This would override the default ignoredNamespaces of the WSDL processor to ['namespaceToIgnore', 'someOtherNamespace']. (This shouldn't be necessary, anyways).

Handling "ignoreBaseNameSpaces" attribute

If an Element in a schema definition depends has a basenamespace defined but the request does not need that value, for example you have a "sentJob" with basenamespace "v20" but the request need only: <sendJob> set in the tree structure, you need to set the ignoreBaseNameSpaces to true. This is set because in a lot of workaround the wsdl structure is not correctly set or the webservice bring errors.

By default the attribute is set to true. An example to use:

A simple ignoredNamespaces object, which only adds certain namespaces could look like this:

var options = {
ignoredNamespaces: true
}

soap-stub

Unit testing services that use soap clients can be very cumbersome. In order to get around this you can use soap-stub in conjunction with sinon to stub soap with your clients.

Example

// test-initialization-script.js
var sinon = require('sinon');
var soapStub = require('soap/soap-stub');

var urlMyApplicationWillUseWithCreateClient = 'http://path-to-my-wsdl';
var clientStub = {
  SomeOperation: sinon.stub()
};

clientStub.SomeOperation.respondWithError = soapStub.createErroringStub({..error json...});
clientStub.SomeOperation.respondWithSuccess = soapStub.createRespondingStub({..success json...});

soapStub.registerClient('my client alias', urlMyApplicationWillUseWithCreateClient, clientStub);

// test.js
var soapStub = require('soap/soap-stub');

describe('myService', function() {
  var clientStub;
  var myService;

  beforeEach(function() {
    clientStub = soapStub.getStub('my client alias');
    soapStub.reset();
    myService.init(clientStub);
  });

  describe('failures', function() {
    beforeEach(function() {
      clientStub.SomeOperation.respondWithError();
    });

    it('should handle error responses', function() {
      myService.somethingThatCallsSomeOperation(function(err, response) {
        // handle the error response.
      });
    });
  });
});

Contributors

changelog

0.25.0 / 2018-08-19

  • [FIX] Improved deserialization on inline simpleType declarations (#1015)
  • [ENHANCEMENT] Added option to allow the user to dis-/enable the timestamp in WSSecurtityCert (defaults to "enabled" to maintain current behaviour) (#1017)
  • [DOC] Updated the "*Async" result description (#1016)
  • [ENHANCEMENT] Added ability to resolve Schema-cross-reference namespaces in client.describe() (#1014)
  • [FIX] Fixed .npmignore patterns in order to publish only the necessary files (#1012)
  • [DOC] Removed formatting in code (#1011)
  • [ENHANCEMENT] Added initial NTLM support (#887)
  • [ENHANCEMENT] Added optional async authentication for the server (#1002)
  • [MAINTENANCE] End of support for node < 6.x in our Travis CI config!
  • [MAINTENANCE] Removed unnecessary selectn dependency (#975)
  • [ENHANCEMNET] Added support for attributes in root elements (#910)
  • [ENHANCEMENT] Added/updated TypeScript definitions (#991)
  • [ENHANCEMENT] Change signature of server.authorizeConnection() to include also the response param. (#1006)
  • [FIX] WSSE Template - fix behaviour for template compilation in __dirname "unsafe" environments (e.g. webpack with target node) (#1008)

0.24.0 / 2018-04-05

  • [DOC] Error on custom deserializer example (#1000)
  • [DOC] Fix broken link
  • [DOC] adding bullets to separate each option
  • [DOC] changed ClientSSLSecurity to ClientSSLSecurityPFX in the readme file
  • [DOC] clarify section on client events in Readme.md (#989)
  • [ENHANCEMENT] Added one-way response configuration options
  • [ENHANCEMENT] Adding support for SOAP 1.2 Envelope Headers in the server side (#1003)
  • [ENHANCEMENT] Enable multiArgs during promisification
  • [ENHANCEMENT] add Client.wsdl for accessing client.wsdl during soap.createClient() (#990)
  • [ENHANCEMENT] add option to remove element-by-element namespacing of json arrays (#994)
  • [ENHANCEMENT] add rawRequest to callback arguments (#992)
  • [FIX] Fixed checking for empty obj.Body before further actions (#986)
  • [FIX] Lookup definitions in child element first (#958)
  • [FIX] only detect xsi:nil if its value is true (#983)
  • [MAINTENANCE] Updating the coverage to use the new version of Istanbul framework, the nyc.
  • [MAINTENANCE] Upgrade Lodash to 4.17.5 (#1001)

0.23.0 / 2017-10-18

  • [FIX] Fixing tests broken by #979
  • [FEATURE] replace non identifier chars to underscore (#978)
  • [FEATURE] Pool keep alive connections if forever option is used (#979)
  • [MAINTENANCE] Use assert.ifError function in tests (#976)
  • [FEATURE] Add function support for server addSoapHeader (#977)

0.22.0 / 2017-10-02

  • [ENHANCEMENT] Added forever option to ClientSSLSecurity in order to allow keep-alive connections. (#974)
  • [ENHANCEMENT] Added preserveWhitespace option to prevent the client from trimming resolved String values. (#972)
  • [MAINTENANCE] Removed compres dependency in favor of zlib. (#971)
  • [MAINTENANCE] (Security) Updated debug dependency to avoid possible vulnerability. (#973)
  • [FIX] Updated .travis.yml to test against latest node.js 4.8.x release to avoid Travis CI error.
  • [FIX] Fix performance bug at POJO to XML conversion. (#968)
  • [ENHANCEMENT] Added possibility to override the bluebird.js suffix (default: "async"). (#961)
  • [DOC] Updated the Security section by listing all available optional methods. (#966)

0.21.0 / 2017-08-28

  • [DOC] Removed issues from Contributing Readme (#963)
  • [DOC] Add server option details to readme.md (#965)
  • [DOC] Added details to clientSSLSecurity (#960)
  • [ENHANCEMENT] Added 'useEmptyTag' wsdlOption, which if set, creates <Tag /> instead of <Tag></Tag> if no body is present (#962)
  • [ENHANCEMENT] Add typescript support (#955)
  • [FIX] path.resolve cannot resolve a null path (#959)
  • [MAINTENANCE] Updated minimum node version to 4.0.0 (#964)
  • [MAINTENANCE] Update uuid library to latest release (3.1.0) and use their newly introduced "modules" instead of the outdated/deprecated direct method calls.
  • [MAINTENANCE] Fixed JSHint indentation errors in test/client-test.js.

0.20.0 / 2017-08-08

  • [ENHANCEMENT] Added bluebird.js promise library in order to provide [methodName]Asyc in Client (#956)
  • [ENHANCEMENT] Added option to handle nilAsNull in SOAP responses (#952)
  • [ENHANCEMENT] Added option to return a SOAP Fault instead of stack (error) on bad request (#951)
  • [MAINTENANCE] Removed uneccessary variable declaration in http.js (#948)
  • [ENHANCEMENT] Added possibiltiy to alter XML before it is sent (#943)
  • [FIX] Updated vulnerable module finalhandler to version ^1.0.3 (#946)
  • [ENHANCEMENT] Added possibility to submit XML-Strings to SOAP Client API (#918)

0.19.2 / 2017-06-12

  • [FIX] Recursive types cause infinite loop (#940)
  • [DOC] Adding a note about consulting in the README. (#939)
  • [MAINTENANCE] Add yarn.lock to gitignore (#938)
  • [MAINTENANCE] Remove dependency to ursa (#928)

0.19.1 / 2017-05-30

  • [FIX] Reverting #914. It broke existing behavior and prevented array type arguments. (#937)
  • [FIX] Add test for accepting array as parameter based on wsdl (#933)
  • [DOC] readme.md clarifications, examples and typos (#930)
  • [MAINTENANCE] Fix build by satisfying jshint indentation (#931)
  • [MAINTENANCE] Drop travis-ci test support for node.js < 4.x (LTS) (#932)
  • [DOC] Update CONTRIBUTING.md
  • [DOC] typo in server example (#925)

0.19.0 / 2017-03-16

  • [FIX] Fixed missing namespace declaration on Array if the namespace is already declared with another prefix. (#923)
  • [DOC] Fix spelling error (#917)
  • [FIX] Add sequence to field if it's defined within the complextType (#914)
  • [MAINTENANCE] Drop deprecated node-uuid package and use the uuid (successor) instead (#913)
  • [FIX] Only add references for the soap:Body and wsse:Security/Timestamp elements in WSSecurityCert (#911)
  • [MAINTENANCE] Updated ejs package version in package.json (#908)
  • [ENHANCEMENT] Added possiblity to pass your own "custom deserializer" within the wsdlOptions in createClient() method (#901)
  • [ENHANCEMENT] Added possibility to use your own "exchange ID" (#907)
  • [ENHANCEMENT] Added "exchange ID" (eid) in emitted client events (#903)
  • [ENHANCEMENT] Added option to suppress error stack in server response (#904)
  • [FIX] Set namespace prefix for first element if elementFormDefault=unqualified (#905)
  • [FIX] Fixed test (use assert instead of should() chain) in test/server-test.js (#906)
  • [DOC] Fix documentation in test/request-response-samples/README.md (#900)

0.18.0 / 2016-11-25

  • [DOC] Added documentation for adding custom http header (#890)
  • [DOC] Update soap stub example (#883)
  • [ENHANCEMENT] Add body parameter to soap responding stub. (#897)
  • [ENHANCEMENT] Added Stream support. (#837)
  • [ENHANCEMENT] Avoid matching <x:Envelope> tags inside comments (#877)
  • [FIX] Ensure that supplied request-object is passed through. (#894)
  • [FIX] Fix exception 'Parameter 'url' must be a string, not object' (#870)
  • [FIX] Handle empty SOAP Body properly. (#891)
  • [FIX] Set lodash dependency version to ^3.10.1 (#895)
  • [MAINTENANCE] Fix test case description (#886)
  • [MAINTENANCE] Fixed request-response-samples-test so that tests with only request.xml and request.json actually get run (#878)
  • [MAINTENANCE] Fixing minor jshint issues. (#884)

0.17.0 / 2016-06-23

  • [ENHANCEMENT] Add option for disabling the WSDL cache (#876)
  • [DOC] Add escapeXML option to README file (#874)
  • [DOC] updated readme for express support (#873)
  • [ENHANCEMENT] express server support (#872)
  • [ENHANCEMENT] better error 1. SOAP message missing evelope and body 2. request/response tests (#869)
  • [FIX] Fix possible crash when send empty post using postman (#861)
  • [FIX] fix ExtensionElement description to match order (#866)
  • [DOC] Added descriptions for actor, hasNonce & mustUndertand options (#865)
  • [FIX] Fix namespaces in client soap requests (#863)
  • [FIX] Always submit valid XML from the client. (#862)
  • [MAINTENANCE] mustUnderstand must be 0 or 1.. with tests (#850)
  • [MAINTENANCE] Remove special handling of methods only taking a string paramter (#854)

0.16.0 / 2016-06-23

  • [ENHANCEMENT] Add nonce and soap:actor support for WSSecurity (#851)
  • [MAINTENANCE] Fix typo in readme (#853)
  • [FIX fixes and issue that causes the module to break if no re or req.headers present in client (#852)
  • [FIX] fixed the soap request envelop generation part when request has complex Type as root. (#849)
  • [FIX] Gracefully handle errors while parsing xml in xmlToObject and resume the parser with p.resume() (#842)
  • [FIX] XSD import in WSDL files and relative path (server creation) - resubmit (#846)
  • [ENHANCEMENT] Support array of certs for ClientSSLSecurity ca. (#841)
  • [MAINTENANCE] Attribute value of body id in double quotes (#843)
  • [MAINTENANCE] Bumping ursa to 0.9.4 (#836)
  • [ENHANCEMENT] Optionally add Created to wssecurity header (#833)
  • [MAINTENANCE] Clean up brace style (#835)
  • [FIX] Fix custom http client not being used when fetching related resources (#834)

0.15.0 / 2016-05-09

  • [FIX] Make ursa an optional dependency since it's currently nearly impossible to install soap on a windows machine otherwise (#832)
  • [FIX] Fixed issue of referencing element in another namespace (#831)
  • [FIX] Fixed incorrect WSDL in CDATA tests (#830)
  • [FIX] Added mocks for node.js streams cork/uncork in tests (for node >= 4.x) (#829)
  • [ENHANCEMENT] Added basic CDATA support (#787)
  • [DOC] Added missing documentation about Client.setEndpoint(url) (#827)
  • [ENHANCEMENT] Added toc node-module in order to generate TOC in README.md via npm run toc command (#826)
  • [FIX] Fix elementFormDefault handling (#822)
  • [FIX] Added missing compress node-module to package.json dependencies (#823)
  • [ENHANCEMENT] The client response event is now triggered with the "raw" IncomingMessage object as second parameter (#816)
  • [DOC] Added note about the keep-alive workaround to prevent truncation of longer chunked reponses in node > 0.10.x (#818)
  • [ENHANCEMENT] Make it possible to overwrite the request module, e.g. for using multipart-body for file up- and downloads (#817)

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

  • [FIX] Maintain ignoredNamespaces option when processing WSDL includes (#796)
  • [ENHANCEMENT] SOAP Headers for server response & changeSoapHeader() method for client & server (#792)
  • [ENHANCEMENT] Added XML declaration (version & encoding) to client requests (#797)
  • [DOC] Added example for server.options to README, fixed typos in CONTRIBUTING (#798)
  • [FIX] Keep nsContext stack consistent even on recursive calls (#799)
  • [FIX] Prevent NPE when processing an empty children array (#789)

0.12.0 / 2016-02-02

  • [MAINTENANCE] updating lodash to 3.x.x
  • [FIX] Schema overwrite when include a xsd with xsd:include (#788)

0.11.4 / 2016-01-09

  • [MAINTENANCE] Adding coverage to project.

0.11.3 / 2016-01-09

  • [ENHANCEMENT] Overriding the namespace prefix with empty prefix. (#779)
  • [FIX] Wrong namespace on elements when complexType has same name. (#781)
  • [FIX] Improved 'https' pattern matching for local files with name starting with 'http'. (#780)
  • [FIX] Handles SOAP result null output. (#778)

0.11.2 / 2016-01-08

  • [FIX] Return null instead of empty object. (#733, #707, #784)
  • [DOC] Adds commas and semicolons to listen(...) example. (#782)
  • [MAINTENANCE] Temporarily skiping test from #768.

0.11.1 / 2015-12-15

  • [ENHANCEMENT] Adding ClientSSLSecurityPFX for use in requests (#768)
  • [FIX] Remove SOAPAction http header in SOAP 1.2, extra header was causing some servers to trip. (#775)
  • [FIX] When an error occur, send HTTP 500 status code. (#774)
  • [FIX] Fixed issue when an error was undefined: undefined. (#771)
  • [FIX] Add missing type attribute for PasswordText in WSSecurity and update related tests. (#754)

0.11.0 / 2015-10-31

  • [ENHANCEMENT] Now passing request to services in server.js. (#769)
  • [ENHANCEMENT] Adding the ability to add headers in client requests. (#770)
  • [MAINTENANCE] Adding gitter badge to README and disabling issues. (#731)
  • [FIX] Stop sending Object prototype methods as XML. (#699)

0.10.3 / 2015-10-23

  • [ENHANCEMENT] Adding createErroringStub to soap-stub. (#765)
  • [ENHANCEMENT] forceSoap12Headers option to add SOAP v1.2 request headers. (#755)

0.10.2 / 2015-10-22

  • [ENHANCEMENT] Adding security to soap-stub. (#764)

0.10.1 / 2015-10-22

  • [ENHANCEMENT] Adding soap-stub. (#763)

0.10.0 / 2015-10-21

  • [FIX] xml namespace/element/type handling. (#756)

0.9.5 / 2015-10-15

  • [FIX] Allow circular XSD files to be loaded. (#745)
  • [ENHANCEMENT] Timestamp is now optional. (#735)
  • [DOC] Formatting History.md 0.9.4 notes.

0.9.4 / 2015-09-28

  • [MAINTENANCE] Adding node v4.0 to .travis.yml. (#729)
  • [MAINTENANCE] Increasing mocha test timeout to 10 seconds. (#732)
  • [FIX] Resolve element references when other types are referenced. (#725)
  • [DOC] Update Readme.md
  • [ENHANCEMENT] New Ignorebasenamespaces option. (#716)
  • [ENHANCEMENT] Add optional statusCode on soap fault. (#715)
  • [FIX] Fix for wsdl retrieval using soap.createClient with special options.httpClient. Before this, the specified client was not used when fetching the wsdl file. This fix will force the wsdl to use the specified httpClient. (#714)
  • [FIX] Allow WSDL to be loaded from HTTPS sites. (#694)

0.9.3 / 2015-09-08

  • [ENHANCEMENT] Allow namespace overriding for elements. (#709)
  • [MAINTENANCE] Disable travis emails.

0.9.2 / 2015-09-08

  • [ENHANCEMENT] Add support for xsd element ref. (#700)
  • [MAINTENANCE] Moving travis build to containers.
  • [MAINTENANCE] Add request sample for an operation without any parameters. (#703)
  • [DOC] update spelling and formatting to clarify several sections of Readme. (#708)
  • [ENHANCEMENT] Add the correct namespace alias for operations without parameters by simply removing the special case where input.parts is empty. If special logic is wanted for this case, it should be contained in objectToRpcXML in any case. (#703)
  • [FIX] Fix a typo in WSDL#findChildParameterObject. (#686)
  • [FIX] Fixed SOAP Fault errors not being raised as errors. (#676)
  • [FIX] Use diffrent namespace styles for soap fault 1.1 and 1.2. (#674)

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. (#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)

0.8.0 / 2015-02-17

  • [ENHANCEMENT] node-soap is now also compatible (and tested) with node v0.12.0 and io.js too. (#571)

  • [FIX] Adds support for attributes in the SOAP Body Element (fixes #386). (#574)

0.7.0 / 2015-02-10

  • [ENHANCEMENT] Server emits a headers event to globally handle SOAP Headers. (#564 )

  • [ENHANCEMENT] A service method can send back a SOAP Fault response to a client by throwing an object that contains a Fault property. (#563)

  • [FIX] Don't throw an Error if an element is not defined. (#562)

  • [ENHANCEMENT] Added more primitive types (['positiveInteger', 'nonPositiveInteger', 'negativeInteger', 'nonNegativeInteger']). (#560)

  • [FIX] Respect empty SOAP actions in operations. (#554)

  • [ENHANCEMENT] The client now emits message, request and soapError events. (#547, #559)

  • [ENHANCEMENT] The server is now aware of the SOAP header(s) from incoming request. (#551)

  • [ENHANCEMENT] Until now, only the SOAP Body was returned from the invoked client method. With this PR also the SOAP Header(s) will be returned. (#539)

0.6.1 / 2014-12-20

  • [ENHANCEMENT] Allow logging of received XML prior to parsing and processing it, which allows better debugging of incomingXML. (#524)

  • [ENHANCEMENT] Add support for importing external wsdl. (#523)

  • [FIX] Use correct namespaces for elements which consist of an array. (#522)

  • [FIX] Use correct namespaces for elements which have a different base namespace. (#521)

  • [FIX] Don't throw an Error when typeElement is undefined in ExtensionElement#description method. (#515)

  • [FIX] Only supply nonce when a password digest is used to avoid schema validation errors. (#496)

  • [FIX] Allow wsdl:documentation element under wsdl:message. (#508)

  • [FIX] Use correct namespaces in sequences with imported elements. (#502)

  • [FIX] Ignore default tns and disabled default tns specification in first element of the body. (#506)

  • [ENHANCEMENT] Define $xml to pass plain XML object. (#485) The $xml key is used to pass an XML Object to the request without adding a namespace or parsing the string.

  • [FIX] Updated '#extend' method to avoid overriding properties and ensure the 'inheritance' of <xsd:extension base=...> usage. (#493)

0.6.0 / 2014-10-29

  • [ENHANCEMENT] Adding bearer security type Exporting security type for usage.
  • [ENHANCEMENT] The qualified elementFormQualified must be respected only when the current element is not a global element. The namespace attribute is only needed if it's not included in the xmlns.
  • [FIX] Remove automatic port appending to "Host" header.
  • [FIX] Avoid creating soap:Header container when there are no children.
  • [FIX] Allowing a 'null' argument for WSDL methods that take no arguments.
  • [FIX] Wrong initialization of xmlns array when handling rpc stype wsdl.
  • [FIX] Fault handling. err should be used less frequently now.
  • [FIX] Added checking if there is input and output for operations under bindings section.
  • [FIX] XSD conflict with same namespace.

0.5.1 / 2014-07-11

  • [ENHANCEMENT] Add "defaults" parameter to BasicAuthSecurity's constructor
  • [ENHANCEMENT] Added possibility to set a custom valueKey for the parsed values from XML SOAP Response
  • [FIX] don't append port 80 to Host if not needed
  • [FIX] Remove possible existing BOM characters from XML String before passing it to WSDL#_fromXML() and parsing it.
  • [FIX] Handling nil attributes in response xml

0.5.0 / 2014-07-11

  • [ENHANCEMENT] Allowing namespace prefixes to be ignored via config.
  • [ENHANCEMENT] wsdl should handle more types
  • [FIX] Handle defined messages ending with "Response", "Out", or "Output"
  • [FIX] Adding default attributesKey to server and allowing the property to be configurable fixing issue #406
  • [FIX] Remove extra characters before and after soap envelope
  • [FIX] Allow operations to not have definitions
  • [FIX] Ignore unknown elements
  • [FIX] Keep ns from top-level
  • [FIX] Check status code of invocation response

0.4.7 / 2014-06-16

  • [ENHANCEMENT] Allow request elements to have both content and attributes.

0.4.6 / 2014-06-16

  • Fix for the elementFormDefault functionality.
  • Fix determining the namespace for complex elements.
  • Add support for the elementFormDefault schema attribute.
  • Fixing duplicate code which had gotten introduced because of a merge.
  • Added the ability to specify elements in a $value attribute for complex types.
  • Allowing the property name "attributes" to be configurable.
  • Fix for andling object arrays.
  • Fix for WSDL and Schema interaction.
  • Allowing response.xml to be optional in tests.
  • Allowing request.xml and response.json to be optional for tests.
  • Fix for adding an undefined XML namespace.
  • Added some documentation on options object when calling createClient.
  • Fix for namespaces in headers not being added appropriately.

0.4.5 / 2014-05-13

  • Fixed: Unspecified binding style defaults to 'document' (#346, #208)
  • Fixed: WSDL parse errors bubble up (#344)
  • Fixed: AssertionError: Invalid child type when WSDL contains imports (#322, #337)
  • Fixed: TargetNamespace not loaded when import in schema (#327, #325)

0.4.4 / 2014-04-16

  • Added namespace prefixes to SOAP headers. #307
  • Provided more documentation around security protocols in the README. #321
  • Added lodash. #321
  • Added a deefault parameter to ClientSSLSecurity. #321
  • Fix to reset the generated namespace number. #308
  • Fixed maximum callstack errors on certain responses. #257

0.4.3 / 2014-04-07

  • Refactored WS-security. small modifications to pull #275
  • Updated readme to add documentation for passing options to a client request
  • Added null check for portType and methods[methodname].output
  • Fixed issue where requests that included compex types led to invalid request XML.
  • Support for attributes array elements and support for complex extensions with array elements.
  • Make sure callback is done asynchronously for a cached wsdl
  • Added WSDL inheritance support (#133).

0.4.2 / 2014-03-13

  • Added the ability to inspect and clear soap headers.
  • Reducing test wsdl size.
  • No longer prefixing elements with a default namespace prefix i.e. xmlns.

0.4.1 / 2014-03-04

Note: an error occurred publishing this version to npm. This version was tagged, so it can be referrenced via git.

  • package; increased minor version to 0.4.1
  • Adding an npmignore on test/
  • Tests are linted
  • Attributes may be added to requests and parsed from responses
  • Tests were added for ssl and client authentication
  • Support for import elements in WSDL documents.
  • Version in server response matches package.json
  • Describe errors fixed on OutputElements.
  • Support for Fault handling.

0.4.0 / 2014-02-15

  • package; increased minor version to 0.4 (xml parser change, tests)
  • remove execute privileges on files #216
  • add travis #219
  • add jshint for index.js #220
  • remove execute permissions on .gitignore #227
  • fixed; fix requests if SOAP service is not on port 80, do not crash on errors #228
  • fixed; undefined value for json in client method when message names end with Out or Output. #243
  • add non xmlns attributes to elements during response parsing #241
  • package; replace expat dependency with sax #246
  • fixed; "Uncaught TypeError: Cannot read property '0' of undefined" #248

0.3.2 / 2014-01-21

  • fixed; http request callback fires twice on error #120
  • fixed; handle connection errors #192
  • package; include mocha in devDependencies