问题
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