Further Attempts - Partly anyway

This commit is contained in:
Fred Boniface 2022-11-28 21:25:13 +00:00
parent 540cc8ae38
commit 807c0b5a9b
3 changed files with 42 additions and 22 deletions

View File

@ -1,2 +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;