I have a class named webserviceCall
.
This is my class structure :
Constructor
--->
Initiate webservice clients and DB handler class and some properties :
public function __construct()
{
$this->username = $GLOBALS['WEBSRVC']['username'];
$this->password = $GLOBALS['WEBSRVC']['password'];
$this->api = $GLOBALS['WEBSRVC']['api'];
$this->loginClient = new SoapClient(NULL, array(
'location' => "http://domain.com/webservice/kks/server.php",
'uri' => "urn://test/webservice") );
$this->booksClient = new SoapClient(null, array(
'location' => "http://domain.com/webservice/kks/books.php",
'uri' => "urn://test/webservice"
));
$this->shopClient = new SoapClient(null, array(
'location' => "http://domain.com/webservice/kks/newShop.php",
'uri' => "urn://test/webservice/shop"
) );
$this->db = new dbHandler($GLOBALS['DBVAR']['dbn'], $GLOBALS['DBVAR']['usn'], $GLOBALS['DBVAR']['psw']);
$this->param = self::freshLogin( $this->username, $this->password, $this->api);
}//__Construct
And there's a method for check Login, based on webservice needs:
protected function freshLogin($username, $password, $api)
{
$currentInfo = $this->db->simple_search('webservice');
$token = ( ($currentInfo[0]['token'] != '') ? $currentInfo[0]['token'] : false );
if( $token == false )
{
$token = $this->loginClient->__soapCall('authenticate', array($currentInfo[0]['username'], $currentInfo[0]['password'], $currentInfo[0]['api']) );
//update token in table
$updateToken = $this->db->update_single('webservice', 'token', $token, true, 'api', $api);
return $token . '||' . $api;
}//token is empty - first login
else
{
$checkToken = $this->loginClient->__soapCall('checkToken', array($token, $api) );
if( isset($checkToken) && $checkToken > 0 )
{
return $token . '||' . $api;
}//if token is valid
else
{
$token = $this->loginClient->__soapCall('authenticate', array($currentInfo[0]['username'], $currentInfo[0]['password'], $currentInfo[0]['api']) );
//update token in table
$updateToken = $this->db->update_single('webservice', 'token', $token, true, 'api', $api);
return $token . '||' . $api;
}//authenticate again, save token and create param value
}//token exists
}//function freshLogin
And finally, there's a method for transact webservice :
public function getBooks()
{
return $this->booksClient->__soapCall('getAllBooks', array($this->param) );
}//function getAllBooks
When I check getBooks()
function with getAllBooks
method, it seems the browser is waiting for the response, and there's no result. This is error:
Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\ketabTheme\PHP\classes\webserviceCall.php on line 114
But When I check exactly the same request in another file, out of a class, it's OK. Besides, when I call another method of webservice inside getBooks
method, again everything is fine.
Would you please help me to find out what's wrong here?
Note :
getBooks
method should have an array with 1935 index in result.
UPDATE :
When I check this request in another file outside a class, this is the request-response timeline :