Discussion:
[nodejs] Re: [node-soap] How do I get http status code in node-soap
Ritesh Gupta
2018-05-21 03:23:57 UTC
Permalink
Code looks like this:



soap.createClient(url, (err, client) => {
if (err) {
logger.error('Error : %s', err);
return;
}

client.setSecurity(new soap.BasicAuthSecurity(username, password));
client.doJob(args, function(err, result, rawResponse, soapHeader,
rawRequest) {
if (err) {
logger.error('Error %s', err.message);

} else {
// Since SOAP Client returns 401 as success, I need to find the http
status
// and act accordingly.
logger.info('success');
},
}, {
timeout: timeout
});
});
Hi,
I have a soap client, which makes a web service call with Basic
Authentication. The web service that I am calling has implemented
app.use(basicAuth({
users: {
'test': 'test123'
}
}));
With this implementation, client (soap client) receives http status code
(as 401) and soap body is empty and my implementation states this as
success.
On client, how do I retrieve this status code to figure out the state of
the response? i tried looking at last "lastResponseHeaders" of soapClient
soap.createClient(url, (err, client) => {
if (err) {
logger.error('Error : %s', err);
return;
}
client.setSecurity(new soap.BasicAuthSecurity(username,
password));
client.doJob(args, function(err, result, rawResponse,
soapHeader, rawRequest) {
if (err) {
logger.error('Error %s', err.message);
} else {
logger.info('success');
}, {
timeout: heartbeatTimeout
}
});
});
Thanks,
Ritesh
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/366bfb1b-4b09-4b61-a899-9c079e27b2e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mikkel Wilson
2018-05-22 22:44:23 UTC
Permalink
Post by Ritesh Gupta
Since SOAP Client returns 401 as success
This sounds extremely unusual. 401 is an HTTP code for a request that
failed authentication. I suspect you don't have the right credentials or
the library isn't sending them in the way the server expects. A 401 status
code could include a body, but it may not be SOAP formatted. Your call here
seems to return both a 'result' and 'rawResponse', have you looked at
those? I'd try logging them to a console and see what you get.

HTH,
Mikkel
https://www.oblivious.io/ <https://www.oblivious.io/?r=googlenodejs>
Post by Ritesh Gupta
soap.createClient(url, (err, client) => {
if (err) {
logger.error('Error : %s', err);
return;
}
client.setSecurity(new soap.BasicAuthSecurity(username, password));
client.doJob(args, function(err, result, rawResponse, soapHeader,
rawRequest) {
if (err) {
logger.error('Error %s', err.message);
} else {
// Since SOAP Client returns 401 as success, I need to find the http
status
// and act accordingly.
logger.info('success');
},
}, {
timeout: timeout
});
});
Hi,
I have a soap client, which makes a web service call with Basic
Authentication. The web service that I am calling has implemented
app.use(basicAuth({
users: {
'test': 'test123'
}
}));
With this implementation, client (soap client) receives http status code
(as 401) and soap body is empty and my implementation states this as
success.
On client, how do I retrieve this status code to figure out the state of
the response? i tried looking at last "lastResponseHeaders" of soapClient
soap.createClient(url, (err, client) => {
if (err) {
logger.error('Error : %s', err);
return;
}
client.setSecurity(new soap.BasicAuthSecurity(username, password));
client.doJob(args, function(err, result, rawResponse,
soapHeader, rawRequest) {
if (err) {
logger.error('Error %s', err.message);
} else {
logger.info('success');
}, {
timeout: heartbeatTimeout
}
});
});
Thanks,
Ritesh
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/7d947be2-2374-4ee6-b8c3-6b42e0a31b41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ritesh Gupta
2018-05-30 09:05:42 UTC
Permalink
Sorry for the late response. When I print rawResponse and result, both are empty:

2018-05-30T08:57:07.355Z - trace: [lib/client.js] Beating...
rawResponse:
result: {}
2018-05-30T08:57:07.380Z - info: [lib/client.js] heartbeat status succesful, breaking....
2018-05-30T08:57:07.380Z - info: [lib/client.js] Heartbeat request completed. Return [true]

in node-soap client.js file, if I add another variable called reponseCode and assign response.statusCode at line 320, i see that status code in my js file

In above log, there is nothing is err and hence the call went into the success criteria.

Regards,
Ritesh
Post by Ritesh Gupta
Since SOAP Client returns 401 as success
This sounds extremely unusual. 401 is an HTTP code for a request that failed authentication. I suspect you don't have the right credentials or the library isn't sending them in the way the server expects. A 401 status code could include a body, but it may not be SOAP formatted. Your call here seems to return both a 'result' and 'rawResponse', have you looked at those? I'd try logging them to a console and see what you get.
HTH,
Mikkel
https://www.oblivious.io/ <https://www.oblivious.io/?r=googlenodejs>
soap.createClient(url, (err, client) => {
if (err) {
logger.error('Error : %s', err);
return;
}
client.setSecurity(new soap.BasicAuthSecurity(username, password));
client.doJob(args, function(err, result, rawResponse, soapHeader, rawRequest) {
if (err) {
logger.error('Error %s', err.message);
} else {
// Since SOAP Client returns 401 as success, I need to find the http status
// and act accordingly.
logger.info <http://logger.info/>('success');
},
}, {
timeout: timeout
});
});
Hi,
app.use(basicAuth({
users: {
'test': 'test123'
}
}));
With this implementation, client (soap client) receives http status code (as 401) and soap body is empty and my implementation states this as success.
soap.createClient(url, (err, client) => {
if (err) {
logger.error('Error : %s', err);
return;
}
client.setSecurity(new soap.BasicAuthSecurity(username, password));
client.doJob(args, function(err, result, rawResponse, soapHeader, rawRequest) {
if (err) {
logger.error('Error %s', err.message);
} else {
logger.info <http://logger.info/>('success');
}, {
timeout: heartbeatTimeout
}
});
});
Thanks,
Ritesh
--
Job board: http://jobs.nodejs.org/ <http://jobs.nodejs.org/>
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md <https://gist.github.com/othiym23/9886289#file-moderation-policy-md>
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines <https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/7d947be2-2374-4ee6-b8c3-6b42e0a31b41%40googlegroups.com <https://groups.google.com/d/msgid/nodejs/7d947be2-2374-4ee6-b8c3-6b42e0a31b41%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/283B8F64-20CF-445B-BE70-6799DF66600F%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...