Compare commits

...

2 Commits

Author SHA1 Message Date
Fred Boniface 807c0b5a9b Further Attempts - Partly anyway 2022-11-28 21:25:13 +00:00
Fred Boniface 540cc8ae38 Attempt re-engineer SOAP Client 2022-11-28 15:22:18 +00:00
4 changed files with 47 additions and 25 deletions

View File

@ -1,6 +1,6 @@
<?php
include("./php/OpenLDBWS.php");
include("./php/LDBWS.php");
include("/srv/keys/athena/apiKeys.php");
$OpenLDBWS = new OpenLDBWS($ldbKey);
$response = $OpenLDBWS->GetArrDepBoardWithDetails(10,BRI,getNonPassengerServices="TRUE");
echo $response
$OpenLDBWS = new Ldb($ldbKey,$trace=true);
$response = $OpenLDBWS->GetArrivalDepartureBoard(10,BRI);
echo $response;

41
php/LDBWS.php Normal file
View File

@ -0,0 +1,41 @@
<?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);
}

View File

@ -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);
}
}

View File

@ -2,26 +2,10 @@
class OpenLDBSVWS
{
private $accessToken;
private $trace;
$wsdl = 'http://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx';
private $wsdl = '<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:sv="http://thalesgroup.com/RTTI/2017-10-01/ldbsv/"
targetNamespace="http://thalesgroup.com/RTTI/2017-10-01/ldbsv/">
<wsdl:import
namespace="http://thalesgroup.com/RTTI/2017-10-01/ldbsv/"
location="http://lite.realtime.nationalrail.co.uk/OpenLDBSVWS/rtti_2017-10-01_ldbsv.wsdl"/>
<wsdl:service name="ldbsv">
<wsdl:port name="LDBSVServiceSoap12" binding="sv:LDBSVServiceSoap12">
<soap12:address location="http://lite.realtime.nationalrail.co.uk/OpenLDBSVWS/ldbsv12.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>';
function __construct($accessToken,$trace=FALSE)
function __construct($accessToken,$trace=TRUE)
{
$this->accessToken = $accessToken;