Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php - using API to UK live rail departure boards

Status
Not open for further replies.

dbrb2

Instructor
Jul 19, 2004
121
GB
Hello - I wonder if someone can give a bit of adice. I came across the API to the UK live train departure boards recently - although I understand it has been around for a while. The interface is described here:


As my first attempt at retreiving some info using it, I used the following bit of php:

Code:
<?
require_once 'SOAP/Client.php';

$wsdl_url = '[URL unfurl="true"]http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx';[/URL]
$wsdl = new SOAP_WSDL($wsdl_url);
$proxy=$wsdl->getProxy();

$response =  $proxy->GetDepartureBoard(10,'KGX');

print_r($response);
?>

I have tried various permutations on the above, but continuously get the error "No crs code required" (where crs code is the three digit station code)

Any ideas?

Cheers,

Ben
 
No - I was using the PEAR soap library for php since it works in older versions of php. As it turns out I am running php 5, so I tried it using the native soap client support, but unfortunately got exactly the same error returned :-(

Code:
<?php
$client = new SoapClient("[URL unfurl="true"]http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx");[/URL]

try{
        $data=$client->GetDepartureBoard(10,"KGX");
}
catch (SoapFault $exception){
        echo 'EXCEPTION='.$exception;
}
print_r($data);
?>
 
Ah...

Well, the my initial attempt using PEAR didn't work, and neither did my first attempt at using native php support.

But passing the parameters in using an array worked fine:

[/code]
<?php
$client = new SoapClient("
$arr = array("crs" => "KGX", "numRows" => 10);

$data=$client->GetDepartureBoard($arr);

print_r($data);
?>
[/code]

Hpowever, using the same fix with thr PEAR library still gave the original error. At least it is working in php 5 now though :-)
 
i think that there may have been an issue with the server. when the question was first posted I was unable to access the server to retrieve the SOAP methods exposed by the API.
 
Glad you got it to work, SOAP is supposed to be easy - it never is !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top