This repository has been archived on 2023-08-24. You can view files and clone it, but cannot push or open issues or pull requests.
athena.fb-infra.uk/php/LDBWS.php

41 lines
1.3 KiB
PHP
Raw Normal View History

2022-11-28 15:22:18 +00:00
<?php
2022-11-28 21:25:13 +00:00
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);
}