Skip to content

Instantly share code, notes, and snippets.

@katronai
Last active June 7, 2018 12:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katronai/798c1c58d69c55e60cb5b9bb96e87f3d to your computer and use it in GitHub Desktop.
Save katronai/798c1c58d69c55e60cb5b9bb96e87f3d to your computer and use it in GitHub Desktop.
Node.js, AWS Lambda - Consume a SOAP service that requires WS-Addressing and v1.2 specification using node-soap module
var soap = require('soap');
var url = 'http://example.org/MyWebService.svc?wsdl';
var soapOptions = {
forceSoap12Headers: true
};
var soapHeader = {
'wsa:Action': 'http://tempuri.org/MyBinding/MyOperation',
'wsa:To': 'http://examle.org/MyWebService.svc'
};
exports.handler = function(event, context, callback) {
var params = {
param1: event.param1,
param2: event.param2
};
soap.createClient(url, soapOptions, function(err, client) {
if (err) callback(err);
client.addSoapHeader(soapHeader, '', 'wsa', 'http://www.w3.org/2005/08/addressing');
client.MyOperation(params, function(err, data) {
if (err) callback(err);
callback(null, data);
});
});
}
@delprofundo
Copy link

delprofundo commented Aug 29, 2017

Did you at any point have issues with soap rejecting the URL parameter? I've been getting a header contains invalid character (empty soapOptions as not using 1.2) ~ only in lambda. Soap wrapper works fine elsewhere

@katronai
Copy link
Author

Sorry for my late reply. I haven't been using Node.js and AWS Lambda for a long time. However, I didn't encounter such an error, as far as I can remember.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment