EDIT:
I was getting an unauthorized fault. Turns out that was because I was supplied with an incorrect token. I've got a working token now, so no longer get unauthorized. However I am still getting an error. Now it is saying 'SOAP-ERROR: Encoding: object hasn't 'numRows' property'
How can I make numRows and crs child nodes of GetDepartureBoardRequest??
Thanks
I'm trying to access Live departures from National Rail Enquiries...
https://staging.livedepartureboards.co.uk/ldbws/
I have an access token.
I'm having issues with generating the client xml and authenticating.
According to the (very limited) docs, my soap envelope should look like this...
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:com="http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes" xmlns:typ="http://thalesgroup.com/RTTI/[put your version here]/ldb/types">
<soapenv:Header>
<com:AccessToken>
<com:TokenValue>XXXXXXXXXXXXXXXXXXXXXXXXXX</com:TokenValue>
</com:AccessToken>
</soapenv:Header>
<soapenv:Body>
<typ:GetDepartureBoardRequest>
<typ:numRows>10</typ:numRows>
<typ:crs>MAN</typ:crs>
</typ:GetDepartureBoardRequest>
</soapenv:Body>
</soapenv:Envelope>
Mine currently looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://thalesgroup.com/RTTI/2012-01-13/ldb/types" xmlns:ns2="http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes">
<SOAP-ENV:Header>
<ns2:AccessToken>
<ns2:TokenValue>XXXXXXXXXXXXXXXXX</ns2:TokenValue>
</ns2:AccessToken>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:GetDepartureBoardRequest/>
<ns1:crs>MAN</ns1:crs>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And this is the PHP I'm using to generate it:
<?php
$token = 'XXXXXXXXXXXXXXXXXXXXXXXXX';
$client = new SoapClient("https://staging.livedepartureboards.co.uk/ldbws/wsdl.aspx",
array('trace' => TRUE));
$headerParams = array('ns2:TokenValue' => $token);
$soapStruct = new SoapVar($headerParams, SOAP_ENC_OBJECT);
$header = new SoapHeader('http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes', 'AccessToken', $soapStruct, false);
$client->__setSoapHeaders($header);
try {
$args = array(
new SoapParam('10','ns1:numRows'),
new SoapParam('WIL','ns1:crs')
);
$response = $client->__call('GetDepartureBoard',$args);
}
catch(Exception $e){
print_r($e);
}
echo "REQUEST:
" . $client->__getLastRequest() . "
";
?>
And finally, this is the SOAP Fault Object I get back:
SoapFault Object
(
[message:protected] => SOAP-ERROR: Encoding: object hasn't 'numRows' property
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /var/www/vhosts/MYSITE.co.uk/httpdocs/live-departures/index.php
[line:protected] => 22
[trace:Exception:private] => Array
(
[0] => Array
(
[function] => __call
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => GetDepartureBoard
[1] => Array
(
[0] => Array
(
[0] => SoapParam Object
(
[param_name] => ns1:numRows
[param_data] => 10
)
[1] => SoapParam Object
(
[param_name] => ns1:crs
[param_data] => MAN
)
)
)
)
)
[1] => Array
(
[file] => /var/www/vhosts/MYSITE.co.uk/httpdocs/live-departures/index.php
[line] => 22
[function] => GetDepartureBoard
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => Array
(
[0] => SoapParam Object
(
[param_name] => ns1:numRows
[param_data] => 10
)
[1] => SoapParam Object
(
[param_name] => ns1:crs
[param_data] => MAN
)
)
)
)
)
[previous:Exception:private] =>
[faultstring] => SOAP-ERROR: Encoding: object hasn't 'numRows' property
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)
This is driving me crazy, I just can't seem to get my head around what's going on. I've read all the PHP SOAP docs, and googled it to breaking point.
Any ideas?