Is there a way to stop PHP SOAP to request each time a function called?

一笑奈何 提交于 2019-12-14 04:26:05

问题


I have a PHP function class which has to work cross-server. So I've searched and decided to try SOAP without WSDL and it worked like a charm. But when there are more than 5-6 function calls ($soap->function()) in one page it generates results really slow. So how can I run that SOAP code like a CLASS that is called one time and get all functions static. Is there a way? Or what should I use instead of SOAP?

calling.php

$options = array(
    "uri" => "https://globalurl",
    "location" => "https://globalurl/soapserver.php",
);
$soap = new SoapClient(null, $options);
$header = new SoapHeader('https://globalurl', 'soapAuth', 'AUTHCODE.KEY', false, SOAP_ACTOR_NEXT);
$soap->__setSoapHeaders($header);

print_r($soap->hashFunction('XXX'));
print_r($soap->siteFunction('XXX'));
print_r($soap->encryptFunction('XXX', '', 2));
print_r($soap->decryptFunction('XXX','', 2));
print_r($soap->remoteIPFunction());

soapserver.php

class soapGlobal {

    public function __construct() {
    }
    public static function hashFunction() {
        //some function...
    }
    public static function siteFunction() {
        //some function...
    }
    public static function encryptFunction() {
        //some function...
    }
    public static function decryptFunction() {
        //some function...
    }
    public static function remoteIPFunction() {
        //some function...
    }

//some more function...

}

$server = new SoapServer(null, array("uri" => "https://globalurl"));
$server->setClass("soapGlobal");
$server->handle();

I need my code to just call a cross-server function class and work with it but without all that delay time. Thank you in advance...

来源:https://stackoverflow.com/questions/57272853/is-there-a-way-to-stop-php-soap-to-request-each-time-a-function-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!