donglv6747 2015-10-02 11:16
浏览 68

使用soapCall里面的方法

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 :

enter image description here

  • 写回答

1条回答 默认 最新

  • duanhao8540 2015-10-02 12:47
    关注

    When you say "But When I check exactly the same request in another file, out of a class, it's OK.", how long does it take?

    You should try increasing the max_execution_time in the php.ini file or by setting: ini_set('max_exeution_time', 60 /*seconds*/) in your PHP script?

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序