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(); + }); + }); + }); });