41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
require('/srv/keys/athena/apiKeys.php');
|
|
$wsdl = 'http://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx';
|
|
|
|
$trace = true;
|
|
$exceptions = true;
|
|
|
|
$soapOptions = array("trace"=>$trace,"soap_version"=>SOAP_1_2,"features"=>SOAP_SINGLE_ELEMENT_ARRAYS);
|
|
|
|
$client = new SoapClient($wsdl, $soapOptions);
|
|
|
|
### BELOW THIS LINE NEEDS ADJUSTING TO NEW ENVIRONMENT -- USE SOAP FLATPAK TO FIND THE CURRENT URL FOR THE HEADER TYPE
|
|
## THE ACCESSTOKEN Var needs changinh to match what is in apiKeys.php
|
|
$soapVar = new SoapVar(array("ns2:TokenValue"=>$accessToken),SOAP_ENC_OBJECT);
|
|
|
|
$soapHeader = new SoapHeader("http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes","AccessToken",$soapVar,FALSE);
|
|
|
|
$client->__setSoapHeaders($soapHeader);
|
|
|
|
|
|
### This is the function to call the API:
|
|
### ACCESSTOKEN VAR ALSO NEEDS CHANGING HERE
|
|
|
|
function call($method,$params)
|
|
{
|
|
try
|
|
{
|
|
$response = $client->$method($params);
|
|
}
|
|
catch(SoapFault $soapFault)
|
|
{
|
|
if ($this->trace)
|
|
{
|
|
$traceOutput["soapFaultMessage"] = $soapFault->getMessage();
|
|
$traceOutput["soapClientRequest"] = str_replace($accessToken,"",$client->__getLastRequest());
|
|
$traceOutput["soapClientResponse"] = $client->__getLastResponse();
|
|
print_r($traceOutput);
|
|
}
|
|
}
|
|
return (isset($response)?$response:FALSE);
|
|
} |