I'm trying to access the National Rail API using node-soap.
Documentation is here: http://ift.tt/16YQLIF
I am new to SOAP so this might not be an issue with the API. I am getting a TypeError with whatever I attempt...
TypeError: Cannot read property 'Body' of undefined
Here is the code I am using to try and make a call:
var soap = require('soap');
var url = 'http://ift.tt/1vbtHvu';
var soapHeader = '<com:AccessToken>MY_TOKEN</com:AccessToken>';
soap.createClient(url, function(err, client){
var args = {
numRows : 10,
crs : 'LAN'
};
client.addSoapHeader(soapHeader);
client.GetDepartureBoard(args, function(err, result){
if(err){
console.log('error!');
throw err;
}
console.log(result);
});
});
Using node-soap I can also get the request envelope, this is the contents:
<soap:Envelope
xmlns:soap="http://ift.tt/sVJIaE"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:tns="http://ift.tt/1vbtHvx"
xmlns:tok="http://ift.tt/16YQLYY"
xmlns:ct="http://ift.tt/1vbtHLL"
xmlns:ldbt="http://ift.tt/12WZM2O"
xmlns:ldbt2="http://ift.tt/1vbtFUh">
<soap:Header>
<com:AccessToken>MY_TOKEN</com:AccessToken>
</soap:Header>
<soap:Body>
<tns:GetDepartureBoardRequest
xmlns:tns="http://ift.tt/1vbtHvx"
xmlns="http://ift.tt/1vbtHvx">
<tns:numRows>10</tns:numRows>
<tns:crs>LAN</tns:crs>
</tns:GetDepartureBoardRequest>
</soap:Body>
</soap:Envelope>
No comments:
Post a Comment