Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing empty response body #672

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading