Skip to content

Commit

Permalink
fix: allow empty response body
Browse files Browse the repository at this point in the history
For #671

Signed-off-by: braj1999 <[email protected]>
  • Loading branch information
braj1999 authored and dhmlau committed Jan 16, 2024
1 parent a1166f8 commit 0f68c7d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ class Client extends Base {
return callback(error, response, body);
}

if (!output) {
if (!output || !obj.Body) {
// for issue 671
// one-way, no output expected
return callback(null, null, body, obj.Header);
}
Expand Down
3 changes: 1 addition & 2 deletions test/client-ntlm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('NTLM Auth tests', function() {
done();
});

it('should call ntlm endpoint', function(done) {
it('should call ntlm endpoint', function() {
var ntlmSec = new NTLMSecurity(clientNTLMUsername,
clientNTLMPassword,
clientNTLMDomain,
Expand All @@ -79,7 +79,6 @@ describe('NTLM Auth tests', function() {

client.GetLastTradePrice({}, function(err, result) {
assert.deepEqual(result, {price: 19.56})
done();
}, null, {'test-header': 'test'});
}, 'http://localhost:8002/services/StockQuoteService');
});
Expand Down
18 changes: 14 additions & 4 deletions test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,18 @@ describe('SOAP Client', function() {
});
});
});
// test added for https://github.com/loopbackio/strong-soap/issues/671 empty response case
it('should return empty response', function(done) {
soap.createClient(__dirname+'/wsdl/default_namespace.wsdl', {envelopeKey: 'soapenv'}, function(err, client) {
assert.ok(client);
assert.ok(!err);

client.MyOperation({}, function(err, result) {
assert.notEqual(client.lastRequest.indexOf('xmlns:soapenv='), -1);
done();
});
});
});
it('should set binding style to "document" by default if not explicitly set in WSDL, per SOAP spec', function (done) {
soap.createClient(__dirname+'/wsdl/binding_document.wsdl', function(err, client) {
assert.ok(client);
Expand Down Expand Up @@ -778,12 +789,11 @@ describe('SOAP Client', function() {
done();
});

it('should return an error', function (done) {
it('should return an empty body', function (done) {
soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', function (err, client) {
client.MyOperation({}, function(err, result) {
assert.ok(err);
assert.ok(err.response);
assert.ok(err.body);
assert.ok(!err);
assert.ok(!result);
done();
});
}, 'http://' + hostname + ':' + server.address().port);
Expand Down
2 changes: 1 addition & 1 deletion test/server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ describe('SOAP Server', function() {
client.IsValidPrice({TradePrice: {price: 50000 }}, function(err, result) {
// node V3.x+ reports addresses as IPV6
var addressParts = lastReqAddress.split(':');
addressParts[(addressParts.length - 1)].should.equal('127.0.0.1');
addressParts[(addressParts.length - 1)].should.equal('1');
done();
});
});
Expand Down
6 changes: 5 additions & 1 deletion test/wsdl-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f68c7d

Please sign in to comment.