<?php
require_once('class.wsdlcache.php');
require_once('nusoap.php');

class BookLink2{
	private $user="amwbsrvceprod";
	private $password="amwbsrvceprod";

	private $wsdlURL ="ProdSecureLogin.wsdl";
	private $namespace="http://webservice.nada.com/";
	private $wsdl;
	
	function __construct(){}
	
	function doing(){
		$this->wsdl = new wsdl("ProdSecureLogin.wsdl");
		$GetTokenRequest = array('Username'=>$user, 'Password'=>$password);
			
		$getToken = array('tokenRequest'=>$GetTokenRequest);
		$client = new nusoap_client($this->wsdl, true);
		$loginToken = $client->call("getToken", array("parameters"=>$getToken), $namespace, "", false, null, "document", "literal");
		
		if($client->response != ''){	
			if($loginToken['detail']['Error']['ErrorMessage']){
				print $loginToken['detail']['Error']['ErrorMessage'];
			}elseif($loginToken['getTokenResult']){
				$_SESSION['token'] =  $loginToken['getTokenResult']; echo "The session Token is {$loginToken['getTokenResult']}";
			}else{
				$_SESSION['tokenerror'] = 'No token';
			}
		}else{
			$_SESSION['responseerror'] = 'No response'; echo "An error occurred: {$client->getError()}";
			$msg = 'No response from data webservice';
			//@mail('info@vehicleduty.com', 'Nada Webservice', $msg);
		}
	}
}
?>