Answer the question
In order to leave comments, you need to log in
Soap request to node js returns undefined, how to fix it?
Can't get response to Soap request using node js. I tested with SoapUI the answer comes, but only undefined through the node. Such a request goes through the UI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.snowball.progmatic.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:getCompetitionDataJSON>
<credentials>
<login>System</login>
<password>Snowball</password>
</credentials>
<competitionId>34</competitionId>
<period>3</period>
</ser:getCompetitionDataJSON>
</soapenv:Body>
</soapenv:Envelope>
var http = require('http');
var body = `
<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.snowball.progmatic.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:getCompetitionDataJSON>
<credentials>
<login>System</login>
<password>Snowball</password>
</credentials>
<competitionId>34</competitionId>
<period>3</period>
</ser:getCompetitionDataJSON>
</soapenv:Body>
</soapenv:Envelope>`;
let url = 'http://test.mobangels.com/snowball/SbService?wsdl';
let postRequest = {
host: 'test.mobangels.com',
path: "snowball/SbService",
// path: "snowball/SbService?wsdl",
port: 80,
method: "POST",
headers: {
'Accept-Encoding': 'gzip,deflate',
'Content-Type': 'text/xml;charset=UTF-8',
'SOAPAction': "getCompetitionDataJSON",
'Host': 'test.mobangels.com',
'Connection': 'Keep-Alive',
'User-Agent': 'Apache-HttpClient/4.1.1 (java 1.5)',
'Content-Length': Buffer.byteLength(body)
}
};
let req = http.request( postRequest, function( res ){
console.log( res.statusCode );
// console.log( res );
var buffer = "";
console.log( 'test' );
res.on( "data", function( data ) { console.log( '_0_', data ); buffer = buffer + data; } );
res.on( "end", function( data ) { console.log('_1_', data ); console.log( '_2_', buffer ); } );
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.write( body );
req.end();
let soap = require('soap');
let url = 'http://test.mobangels.com/snowball/SbService?wsdl';
let args = {
credentials:{
login: 'System',
password: 'Snowball'
},
competitionId: '34',
period: '1',
startFrom: '2017-07-12T15:20:54.120+04:00'
};
var wsdlOptions = {
"overrideRootElement": {
"namespace": "ser",
"xmlnsAttributes": [{
"name": "xmlns:ser",
"value": "http://service.snowball.progmatic.com/"
}]
}
};
let app = express();
soap.createClient(url,wsdlOptions, function(err, client) {
client.getCompetitionDataJSON(args, function(err, result) {
console.log(result);
});
console.log(client.lastRequest)
});
400
test
_1_ undefined
_2_
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://service.snowball.progmatic.com/"><soap:Body><ser:getCompetitionDataJSON xmlns:ser="http://service.snowball.progmatic.com/"><credentials><login>System</login><password>Snowball</password></credentials><competitionId>34</competitionId><period>1</period><startFrom>2017-07-12T15:20:54.120+04:00</startFrom></ser:getCompetitionDataJSON></soap:Body></soap:Envelope>
undefined
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question