Last active
June 7, 2018 12:43
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); | |
} |
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
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