From 807c0b5a9b289537d08473239a4e59529a08f806 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 28 Nov 2022 21:25:13 +0000 Subject: [PATCH] Further Attempts - Partly anyway --- php/LDBWS.php | 41 ++++++++++++++++++++++++++++++++++++++++- php/OpenLDBWS.php | 3 --- php/openLDBSVWS.php | 20 ++------------------ 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/php/LDBWS.php b/php/LDBWS.php index 96212da..3b19da6 100644 --- a/php/LDBWS.php +++ b/php/LDBWS.php @@ -1,2 +1,41 @@ $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); + } \ No newline at end of file diff --git a/php/OpenLDBWS.php b/php/OpenLDBWS.php index 4eff3f5..e79bb42 100644 --- a/php/OpenLDBWS.php +++ b/php/OpenLDBWS.php @@ -37,11 +37,8 @@ if ($this->trace) { $traceOutput["soapFaultMessage"] = $soapFault->getMessage(); - $traceOutput["soapClientRequest"] = str_replace($this->accessToken,"",$this->soapClient->__getLastRequest()); - $traceOutput["soapClientResponse"] = $this->soapClient->__getLastResponse(); - print_r($traceOutput); } } diff --git a/php/openLDBSVWS.php b/php/openLDBSVWS.php index 66d6dc6..dd677c5 100644 --- a/php/openLDBSVWS.php +++ b/php/openLDBSVWS.php @@ -2,26 +2,10 @@ class OpenLDBSVWS { private $accessToken; - private $trace; + $wsdl = 'http://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx'; - private $wsdl = ' - - - - - - - - '; - - function __construct($accessToken,$trace=FALSE) + function __construct($accessToken,$trace=TRUE) { $this->accessToken = $accessToken;