National Rail Enquiries' Live Departure Boards web service

1,874 views
Skip to first unread message

Peter Hicks

unread,
Nov 13, 2014, 3:09:57 PM11/13/14
to openrail...@googlegroups.com
All,

You can now sign up for, and receive an API key for, National Rail
Enquiries' LDBWS at
http://realtime.nationalrail.co.uk/OpenLDBWSRegistration - the T&Cs are
both simpler and less onerous.

Is anyone here planning on using the API for anything?


Peter

Adam Flax

unread,
Nov 14, 2014, 5:14:21 AM11/14/14
to openrail...@googlegroups.com
I'm currently investigating this feed to see if I can use it to fill in missing movements for some stations (the stations that are optional timing points that never get recorded in TRUST)

Adam Flax

unread,
Nov 14, 2014, 5:21:36 AM11/14/14
to openrail...@googlegroups.com
(sorry for spamming up the board but I can't edit my post =-( )
on another note does anyone know what the service id's are encoded in? e.g. yjnJDu6rXAM6MhtwfOUZZg== it looks like base64 but it decodes to gibberish. I was hoping that the decoded message was a nice string that I could work out my self so I can access the
seviceDetails without calling getDepartureBoard

Peter Hicks

unread,
Nov 14, 2014, 5:39:08 AM11/14/14
to openrail...@googlegroups.com
They're just keys, they don't translate to anything that I know of!


Peter

Budgie Byrne

unread,
Dec 12, 2014, 1:53:19 PM12/12/14
to openrail...@googlegroups.com
Was planning on making a pebble watch app to get the times of the next train home from the nearest station, there's already a pebble app to get times of departures from a given station, but no way to filter the services by destination.

Trouble is, after getting my token, I can't get the SOAP request to authenticate. (Complete "noob" - by the way)

I'll keep trying, but happy to accept advice on how to get the request to return some data using JavaScript!

Peter Hicks

unread,
Dec 12, 2014, 5:04:37 PM12/12/14
to openrail...@googlegroups.com
Hi Budgie
Javascript, I can't help with... however somebody else on the list has
been having problems with newly-issued tokens. I've opened a ticket
with the Helpdesk, who are currently investigating.


Peter

Budgie Byrne

unread,
Dec 13, 2014, 3:02:33 AM12/13/14
to openrail...@googlegroups.com
Morning Peter, thanks for getting back to me! I think I'll manage to get the script written up once I eventually get authenticated - I'll keep my ear to the ground, hopefully it'll just be a simple case of having to request a new token!

Is there a thread here to chart your progress with the help desk?

Thanks again!

Peter Hicks

unread,
Dec 13, 2014, 4:09:53 AM12/13/14
to openrail...@googlegroups.com
Hi Budgie

On 13/12/14 08:02, Budgie Byrne wrote:
> Morning Peter, thanks for getting back to me! I think I'll manage to get the script written up once I eventually get authenticated - I'll keep my ear to the ground, hopefully it'll just be a simple case of having to request a new token!
>
> Is there a thread here to chart your progress with the help desk?
There will be once I hear back from them!


Peter

Chris Northwood

unread,
Dec 13, 2014, 6:25:51 AM12/13/14
to Budgie Byrne, openraildata-talk
What's the format of the request you're sending to the SOAP endpoint? You have to send the token in a particular manner, my Darwin integration is in Python and it wasn't straightforward to do that, here's the code for comparison: https://github.com/mollyproject/mollyproject/blob/master/molly/apps/places/providers/ldb.py#L87

It might be easier to help if you could post a few snippets of your code?


--
You received this message because you are subscribed to the Google Groups "A gathering place for the Open Rail Data community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openraildata-t...@googlegroups.com.
To post to this group, send an email to openrail...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Hicks

unread,
Dec 15, 2014, 6:08:25 AM12/15/14
to openraildata-talk
Hi Budgie

I've got to the bottom of the problem - the correct URL to access is https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ - note the 'lite.realtime' and 'OpenLDBWS'.

The old 'LDBWS' service was switched off a couple of weeks ago - although the documentation still refers to the old URL, which I've asked to be changed.

Can you switch your client over to this and report back whether it works or not?

Cheers,


Peter
--
Peter Hicks  |  Poggs Consultancy Services  |  t: 020 3095 2600  |  m: 07970 476447

Budgie Byrne

unread,
Dec 15, 2014, 8:04:14 AM12/15/14
to openrail...@googlegroups.com
Thanks for the update Peter. I'm
Using soapclient.com/soaptest.html to try to get the returned XML document - using the URL you sent with my token still results in the error.

Three things I think may be happening (or a combination of all!):

1: Soapclient.com doesn't play nicely with national rail enquiries
2: My token is incorrect
3: I'm doing something terribly wrong

Have you had any experience with soapclient.com? So far I haven't built anything in JS, didn't want to get started until I knew what the SOAP return value looks like.

Thanks for all your help!

Peter Hicks

unread,
Dec 15, 2014, 8:27:49 AM12/15/14
to openrail...@googlegroups.com
Hi Budgie
Never used it before, however I get an error too.

The request from a 'known good' client is:

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://thalesgroup.com/RTTI/2014-02-20/ldb/" xmlns:ns2="http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes">
  <SOAP-ENV:Header>
    <ns2:AccessToken>
      <ns2:TokenValue>***removed***</ns2:TokenValue>
    </ns2:AccessToken>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:GetDepartureBoardRequest>
      <ns1:numRows>10</ns1:numRows>
      <ns1:crs>MAN</ns1:crs>
    </ns1:GetDepartureBoardRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

From soapclient.com:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://thalesgroup.com/RTTI/2014-02-20/ldb/" xmlns:tok="http://thalesgroup.com/RTTI/2013-11-28/Token/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ct="http://thalesgroup.com/RTTI/2007-10-10/ldb/commontypes" xmlns:prev="http://thalesgroup.com/RTTI/2012-01-13/ldb/types">
  <SOAP-ENV:Header>
    <mns1:AccessToken xmlns:mns1="http://thalesgroup.com/RTTI/2014-02-20/ldb/">
      <TokenValue>***removed***</TokenValue>
    </mns1:AccessToken>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <tns:GetDepartureBoardRequest xmlns:tns="http://thalesgroup.com/RTTI/2014-02-20/ldb/">
      <tns:numRows>10</tns:numRows>
      <tns:crs>MAN</tns:crs>
      <tns:filterCrs/>
      <tns:filterType>to</tns:filterType>
      <tns:timeOffset>0</tns:timeOffset>
      <tns:timeWindow>120</tns:timeWindow>
    </tns:GetDepartureBoardRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I *think* the problem here is that soapclient.com is specifying the AccessToken using a namespace of 'mns1', which is "http://thalesgroup.com/RTTI/2014-02-20/ldb/", but it should really be "http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes".  That'd explain the fact that the web service isn't seeing the AccessToken and therefore returning an 'unauthorised' response.

To test this, I put the XML request from soapclient.com in Postman (for Chrome), set the request type to POST, format to text/xml and submitted it - 401 error.  If I change the mns1 namespace definition in the AccessToken field to 'http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes', I get a valid response.

So, it looks like possibly an issue with the website itself :(


Peter

Budgie Byrne

unread,
Dec 15, 2014, 10:37:43 AM12/15/14
to openrail...@googlegroups.com
Thanks Peter. I think its coming out now that I am a complete beginner with this (And maybe the NRE project I wanted to start wasn't the best pace for me to start considering the lack of documentation!)

I have installed Postman (Much better way to see the result of the request and make changes, so thanks for that!) but am not getting what I expect from the call. Using the working request you made, I still only get this:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions 
    <wsdl:import namespace="http://thalesgroup.com/RTTI/2014-02-20/ldb/" location="rtti_2014-02-20_ldb.wsdl" />
    <wsdl:service name="ldb">
        <wsdl:port name="LDBServiceSoap" binding="tns:LDBServiceSoap">
            <soap:address location="https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb6.asmx" />
        </wsdl:port>
        <wsdl:port name="LDBServiceSoap12" binding="tns:LDBServiceSoap12">
            <soap12:address location="https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb6.asmx" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions> 

I was expecting to see something that looks more like the data on the departure board.

Silly question now: Am I using the correct address to send requests to? I'm sending them to https://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx?ver=2014-02-20



On Thursday, November 13, 2014 8:09:57 PM UTC, Peter Hicks wrote:

Peter Hicks

unread,
Dec 15, 2014, 12:26:37 PM12/15/14
to openrail...@googlegroups.com
Hi Budgie


On 15/12/14 15:37, Budgie Byrne wrote:
Thanks Peter. I think its coming out now that I am a complete beginner with this (And maybe the NRE project I wanted to start wasn't the best pace for me to start considering the lack of documentation!)
It might surprise to you learn that SOAP APIs aren't commonplace and there are a lot of people (me included) who had to do a fair bit of head-scratching.

I'm planning to document this on the Open Data Wiki (http://nrodwiki.rockshore.net/) in the coming weeks so nobody has to start from fresh.
I have installed Postman (Much better way to see the result of the request and make changes, so thanks for that!) but am not getting what I expect from the call. Using the working request you made, I still only get this:
[snip]
That may be my fault - I think I put the wrong URL in the email.

https://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx?ver=2014-02-20 returns the WSDL, which shows the SOAP endpoint of https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb6.asmx - that's the one you need to use, and it'll accept an HTTP POST.


Peter

Budgie Byrne

unread,
Dec 15, 2014, 12:50:23 PM12/15/14
to openrail...@googlegroups.com

Certainly do feel like this is all working against me now! Any ideas what I'm doing wrong?

Clipped line 2 reads: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://thalesgroup.com/RTTI/2014-02-20/ldb/" xmlns:ns2="http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes">

(Also, you should add a donate button to the wiki - I definitely owe you a coffee for your help with this!)

Chris Bailiss

unread,
Dec 15, 2014, 12:57:43 PM12/15/14
to openrail...@googlegroups.com

Just to add an alternative view (that perhaps won't be popular here!) but SOAP is quite common in the Microsoft-technology world.  Using Visual Studio yesterday I was able to consume the WSDL URL and having a working prototype running in about ten minutes total.

I mention it because using Visual Studio to automatically generate the proxy classes is likely to be one of the simpler ways of accessing the LDB service.  The only code I needed to write for my prototype was:

                AccessToken oAccessToken = new AccessToken();
                oAccessToken.TokenValue = "my security token here";

                LDBServiceSoapClient oClient = new LDBServiceSoapClient();
                var oResponse = await oClient.GetArrivalDepartureBoardAsync(oAccessToken, 200, textBox1.Text, null, FilterType.from, 0, 120);

Chris

Peter Hicks

unread,
Dec 15, 2014, 1:03:10 PM12/15/14
to openrail...@googlegroups.com

On 15/12/14 17:57, Chris Bailiss wrote:
> Just to add an alternative view (that perhaps won't be popular here!)
> but SOAP is quite common in the Microsoft-technology world. Using
> Visual Studio yesterday I was able to consume the WSDL URL and having
> a working prototype running in about ten minutes total.
>
> I mention it because using Visual Studio to automatically generate the
> proxy classes is likely to be one of the simpler ways of accessing the
> LDB service. The only code I needed to write for my prototype was:
>
> AccessToken oAccessToken = new AccessToken();
> oAccessToken.TokenValue = "my security token here";
>
> LDBServiceSoapClient oClient = new LDBServiceSoapClient();
> var oResponse = await
> oClient.GetArrivalDepartureBoardAsync(oAccessToken, 200,
> textBox1.Text, null, FilterType.from, 0, 120);
>
Really? I never knew that! It explains perfectly why it's so prevalent
but only in certain sections of tech.

Is that literally the only code you need for Visual Studio? Would you
mind if I shoved that on the wiki? :)


Peter

Chris Bailiss

unread,
Dec 15, 2014, 1:25:11 PM12/15/14
to openrail...@googlegroups.com

Yes, that is literally all the code I needed to write by hand to interact with the LDB service.  Of course, that snippet of code doesn't do anything with the results, but that's all that is needed to get an LDB for a particular station.

To put a bit more meat on it for the wiki page, a more fuller description of how to consume the service in the Microsoft world is:
  1. Install the Visual Studio IDE if not done already (cost-free versions for single developers are available, e.g. the Express Editions).
  2. Create a new project following the usual steps (e.g. console app, web project, windows forms project, etc).
  3. In Solution Explorer, on the "Service References" folder, go to "Add Service Reference".
  4. In the Address box, enter the current WSDL URL, e.g. at the time of writing:
    https://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx?ver=2014-02-20
  5. In the Namespace box, enter an appropriately descriptive namespace, e.g. LDB
  6. Click OK.  Visual Studio will now download the WSDL and associated schemas.  It will then auto generate all the code in the proxy classes necessary to interact with the service.
  7. At the top of your code file, reference the created classes by adding a using statement, e.g.
    using YourProjectNameHere.LDB;
  8. Use code similar to that in my earlier message to invoke the remote service and retrieve a live arrival/departure board.  The code may vary slightly depending on project (my example uses a windows form containing a single text box, textBox1, where I entered the CRS code), the .NET language (my example was C#) and also whether or not you are using the async features of .NET (if not, remove the await keyword).
  9. Iterate through the lines of the LDB to do whatever you need to do with the results, e.g. using:
foreach (var oService in oResponse.GetStationBoardResult.trainServices)
{
...

Budgie Byrne

unread,
Dec 16, 2014, 4:56:32 AM12/16/14
to openrail...@googlegroups.com
Just thought I'd let you know that I managed to solve this - Can't say what the problem was, but I found another website for sending SOAP requests similar to soapclient.com - worked first time using the exact same request that failed in Postman (Stupidly didn't make a note of the page, and am now at work, I'll update later!).

So I have now managed to build a rough version of my app to get the times between my home and work station on my watch :) Need to add a few more bits to show arrival time/departure platform, but all the pieces are there now...Thanks for your help, Peter!

Dave Butland

unread,
Dec 18, 2014, 3:46:00 AM12/18/14
to openrail...@googlegroups.com
Chris, 

Part of me wants to give you the response you expect but have been working with Micro$oft technology Web Service at work recently and I'm extremely impressed at how quickly the developers can consume new services using these classes.

Peter, 

I'm going to look at this interface over the holidays whilst deploying the production servers. I'll post the java equivalent if I get it working. Isn't much more complicated but it's been awhile since I used SOAP. Json is so much easier. 

Dave.

John Slevin

unread,
Dec 19, 2014, 6:42:29 AM12/19/14
to openrail...@googlegroups.com
Re Chris Bailiss using Microsoft Visual Studio - 100% agree - as he said, takes a few minutes to get up and running - I don't pretend to understand SOAP - didn't need to.
Re Peter Hicks "Is anyone here planning on using the API for anything?" yes see http://www.wigancentral.bar/images/slider10.jpg extreme left side of image is my live departure board (its a windows form not web page)
cheers
john

su...@matzgroup.in

unread,
May 14, 2016, 6:07:39 AM5/14/16
to A gathering place for the Open Rail Data community
Hi Dave,
I am not sure if you are still following this topic. But wanted to know if you have the Java equivalent running client for LDBWS. Any help is much appreciated!

Sunil

On Thursday, December 18, 2014 at 2:16:00 PM UTC+5:30, Dave Butland wrote:
> Chris, 
>
>
> Part of me wants to give you the response you expect but have been working with Micro$oft technology Web Service at work recently and I'm extremely impressed at how quickly the developers can consume new services using these classes.
>
>
> Peter, 
>
>
> I'm going to look at this interface over the holidays whilst deploying the production servers. I'll post the java equivalent if I get it working. Isn't much more complicated but it's been awhile since I used SOAP. Json is so much easier. 
>
>
> Dave.
>
> On Monday, 15 December 2014 18:25:11 UTC, Chris Bailiss wrote:
>
>
>
>
> Yes, that is literally all the code I needed to write by hand to interact with the LDB service.  Of course, that snippet of code doesn't do anything with the results, but that's all that is needed to get an LDB for a particular station.
>
>
> To put a bit more meat on it for the wiki page, a more fuller description of how to consume the service in the Microsoft world is:
> Install the Visual Studio IDE if not done already (cost-free versions for single developers are available, e.g. the Express Editions).Create a new project following the usual steps (e.g. console app, web project, windows forms project, etc).In Solution Explorer, on the "Service References" folder, go to "Add Service Reference".In the Address box, enter the current WSDL URL, e.g. at the time of writing:
> https://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx?ver=2014-02-20In the Namespace box, enter an appropriately descriptive namespace, e.g. LDBClick OK.  Visual Studio will now download the WSDL and associated schemas.  It will then auto generate all the code in the proxy classes necessary to interact with the service.At the top of your code file, reference the created classes by adding a using statement, e.g.
> using YourProjectNameHere.LDB;
> Use code similar to that in my earlier message to invoke the remote service and retrieve a live arrival/departure board.  The code may vary slightly depending on project (my example uses a windows form containing a single text box, textBox1, where I entered the CRS code), the .NET language (my example was C#) and also whether or not you are using the async features of .NET (if not, remove the await keyword).Iterate through the lines of the LDB to do whatever you need to do with the results, e.g. using:
Reply all
Reply to author
Forward
0 new messages