I am using the following: http://www.ukverify.co.uk/webservice.asmx
I create the token using:
<?php
$wsdl = "http://www.ukverify.co.uk/webservice.asmx?wsdl";
$client = new SoapClient($wsdl,
array(
"trace" => 1, // enable trace to view what is happening
"exceptions" => 1, // disable exceptions
"cache_wsdl" => 0) // disable any caching on the wsdl, encase you alter the wsdl server
);
$username='myusername';
$password='mypassword';
$token='';
$ns = 'http://ukverify.co.uk/';
$client = new SoapClient("http://www.ukverify.co.uk/webservice.asmx?wsdl",
array(
"trace" => 1, // enable trace to view what is happening
"exceptions" => 1, // disable exceptions
"cache_wsdl" => 0) // disable any caching on the wsdl, encase you alter the wsdl server
);
$headerbody = array('Username'=>$username,'Password'=>$password);
$header = new SoapHeader($ns,'WebServiceHeader',$headerbody);
$client->__setSoapHeaders($header);
$apiToken = $client->AuthenticateUser()->AuthenticateUserResult;
?>
I am now trying to use BSearch. I now have to use the token in the header and pcode in the body. The closest I can get after hours of trying different syntax guesses is:
$wsdl = "http://www.ukverify.co.uk/webservice.asmx?wsdl";
$client = new SoapClient($wsdl,
array(
"trace" => 1, // enable trace to view what is happening
"exceptions" => 1, // disable exceptions
"cache_wsdl" => 0) // disable any caching on the wsdl, encase you alter the wsdl server
);
$username='myusername';
$password='mypassword';
$token='';
$ns = 'http://ukverify.co.uk/';
$client = new SoapClient("http://www.ukverify.co.uk/webservice.asmx?wsdl");
$headerbody = array('Username'=>$username,'Password'=>$password);
$header = new SoapHeader($ns,'WebServiceHeader',$headerbody);
$client->__setSoapHeaders($header);
$apiToken = $client->AuthenticateUser()->AuthenticateUserResult;
//echo $apiToken;
// Setup the SOAP Header
$authHeader = array('AuthenticatedToken'=>$apiToken);
$header = new SoapHeader($ns,
'WebServiceHeader',
$authHeader, false
);
$client->__setSoapHeaders($header);
$params = array('pcode' => 'sw15 2au');
$response = $client->__soapCall('BSearch',array("parameters" => array('pcode'=> "sw15 2au")));
// $response = $client->__soapCall('BSearch',array("parameters" => array('pcode'=> $params)));
//$response = $client->AddressFill($params);
var_dump($response);
class AuthHeader
{
var $APIToken;
function __construct()
{
}
}
The error is:
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in /home/wilseayd/public_html/idChecka/hanson3.php:40 Stack trace: #0 /home/wilseayd/public_html/idChecka/hanson3.php(40): SoapClient->__soapCall('BSearch', Array) #1 {main} thrown in /home/wilseayd/public_html/idChecka/hanson3.php on line 40
Can anyone construst the PHP code correctly?
Getting a result with:
<?php
$client = new SoapClient('http://www.ukverify.co.uk/webservice.asmx?wsdl');
$username='xxx';
$password='xxx';
$token='';
$ns = 'http://ukverify.co.uk/';
$headerbody = array('Username'=>$username,'Password'=>$password);
$header = new SoapHeader($ns,'WebServiceHeader',$headerbody);
$client->__setSoapHeaders($header);
$apiToken = $client->AuthenticateUser()->AuthenticateUserResult;
$_SESSION['apiToken']= $apiToken;
// Do the above once
// Reuse the below
$headerbody = array('AuthenticatedToken' => $apiToken);
$header = new SoapHeader($ns,'WebServiceHeader',$headerbody);
$params = array('firstname' => "",'surname' => "warburton",'pafbldg' =>"",'pafpremno' => "",
'pafstreet' => "",'pafarea' => "",'town' => "",'pcode' => 'OL6 9rs');
$client = new SoapClient('http://www.ukverify.co.uk/webservice.asmx?wsdl');
$client->__setSoapHeaders($header);
$results = $client->BSearch($params);
var_dump($results);
?>
Now the issue is how do I use the data that is returned. Ideally I need it in JSON format so I can consume the data from a mobile app.
The result is ( viewing the source code of the outputted page):
object(stdClass)#1 (1) {
["BSearchResult"]=>
object(stdClass)#2 (2) {
["schema"]=>
string(1065) "<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="xyzzy"><xs:element name="xyzzy" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="xyzzy"><xs:complexType><xs:sequence><xs:element name="title" type="xs:string" minOccurs="0"/><xs:element name="firstname" type="xs:string" minOccurs="0"/><xs:element name="initial" type="xs:string" minOccurs="0"/><xs:element name="surname" type="xs:string" minOccurs="0"/><xs:element name="dob" type="xs:string" minOccurs="0"/><xs:element name="pafpremno" type="xs:string" minOccurs="0"/><xs:element name="pafbldg" type="xs:string" minOccurs="0"/><xs:element name="pafstreet" type="xs:string" minOccurs="0"/><xs:element name="town" type="xs:string" minOccurs="0"/><xs:element name="county" type="xs:string" minOccurs="0"/><xs:element name="pcode" type="xs:string" minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema>"
["any"]=>
string(1129) "<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><xyzzy xmlns=""><xyzzy diffgr:id="xyzzy1" msdata:rowOrder="0"><title>Ms</title><firstname>xxxx</firstname><initial xml:space="preserve"> </initial><surname>xxxxx</surname><dob>45 to 54</dob><pafpremno>29</pafpremno><pafbldg/><pafstreet>Mossley Road</pafstreet><town>Ashton-Under-Lyne</town><county>Lancashire</county><pcode>OL6 9RS</pcode></xyzzy><xyzzy diffgr:id="xyzzy2" msdata:rowOrder="1"><title>Mr</title><firstname>xxx</firstname><initial>J</initial><surname>xxx</surname><dob>45 to 54</dob><pafpremno>29</pafpremno><pafbldg/><pafstreet>Mossley Road</pafstreet><town>Ashton-Under-Lyne</town><county>Lancashire</county><pcode>OL6 9RS</pcode></xyzzy><xyzzy diffgr:id="xyzzy3" msdata:rowOrder="2"><title>Mr</title><firstname>xxxx</firstname><initial>D</initial><surname>xxxx</surname><dob>18 to 24</dob><pafpremno>29</pafpremno><pafstreet>Mossley Road</pafstreet><town>Ashton-Under-Lyne</town><county>Lancashire</county><pcode>OL6 9RS</pcode></xyzzy></xyzzy></diffgr:diffgram>"
}
}
Heres Hopin.
Mr Warby