From bcc41e6c41e79d2cbbca8887c2fdb36502b10d36 Mon Sep 17 00:00:00 2001 From: Caleb Date: Fri, 23 Mar 2018 02:46:27 -0700 Subject: [PATCH] Adding support for SOAP 1.2 Envelope Headers in the server side (#1003) * forceSoap12Header effects server side envelope header now * adding tests for forceSoap12Headers --- lib/server.js | 7 +++- test/server-options-test.js | 68 +++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index 92d8f2c06..4d3642903 100644 --- a/lib/server.js +++ b/lib/server.js @@ -401,8 +401,13 @@ Server.prototype._envelope = function (body, headers, includeTimestamp) { ns = defs.$targetNamespace, encoding = '', alias = findPrefix(defs.xmlns, ns); + + var envelopeDefinition = this.wsdl.options.forceSoap12Headers + ? "http://www.w3.org/2003/05/soap-envelope" + : "http://schemas.xmlsoap.org/soap/envelope/" + var xml = "" + - "'; diff --git a/test/server-options-test.js b/test/server-options-test.js index 44e2da213..b652ec405 100644 --- a/test/server-options-test.js +++ b/test/server-options-test.js @@ -330,4 +330,72 @@ describe('SOAP Server with Options', function() { ); }); }); + it('should not return a SOAP 12 envelope when headers are not forced', function(done) { + test.server.listen(15099, null, null, function() { + test.soapServer = soap.listen(test.server, { + path: '/stockquote', + services: test.service, + xml: test.wsdl, + uri: __dirname + '/wsdl/strict/', + forceSoap12Headers: false + }, test.service, test.wsdl); + test.baseUrl = 'http://' + test.server.address().address + ":" + test.server.address().port; + + //windows return 0.0.0.0 as address and that is not + //valid to use in a request + if (test.server.address().address === '0.0.0.0' || test.server.address().address === '::') { + test.baseUrl = 'http://127.0.0.1:' + test.server.address().port; + } + // console.log(test.baseUrl); + request.post({ + url: test.baseUrl + '/stockquote', + body: '' + + ' ' + + ' ' + + '' + }, function(err, res, body) { + assert.ifError(err); + assert.ok( + body.indexOf('xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"') > -1 + ) + done(); + }); + }); + }); + it('should return a SOAP 12 envelope when headers are forced', function(done) { + test.server.listen(15099, null, null, function() { + test.soapServer = soap.listen(test.server, { + path: '/stockquote', + services: test.service, + xml: test.wsdl, + uri: __dirname + '/wsdl/strict/', + forceSoap12Headers: true + }, test.service, test.wsdl); + test.baseUrl = 'http://' + test.server.address().address + ":" + test.server.address().port; + + //windows return 0.0.0.0 as address and that is not + //valid to use in a request + if (test.server.address().address === '0.0.0.0' || test.server.address().address === '::') { + test.baseUrl = 'http://127.0.0.1:' + test.server.address().port; + } + // console.log(test.baseUrl); + request.post({ + url: test.baseUrl + '/stockquote', + body: '' + + ' ' + + ' ' + + '' + }, function(err, res, body) { + assert.ifError(err); + assert.ok( + body.indexOf('xmlns:soap="http://www.w3.org/2003/05/soap-envelope"') > -1 + ) + done(); + }); + }); + }); });