0

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...

ValDiMagra
  • 73
  • 1
  • 8
  • SOAP executes on the remote server, that is by design, that is the point of SOAP, it is an API. Unless there's a good reason, you probably don't want your remote server doing trival tasks that a class or library on the client side can do. – Scuzzy Aug 13 '19 at 21:51
  • Thank you again, so what should I do to use same class in 3-4 different servers, 20-30 different domains? And if some of those domains are not mine to trust getting hands on my global functions is there a better way besides an API? – ValDiMagra Aug 14 '19 at 16:48
  • And also I need that functions to access global database which is placed on one server that class is working on. Let me clear my needs: I need a system to use functions which are working on a database (global) to make things syncronized and other functions that are used for same purpose on 20-30 domains. Some of those projects are mine but some of them are for customers so I didn't want them to access my functions freely (maybe after we cancel updates). So what should I use to maintain those needs? Is there any other option besides SOAP? CORS maybe? – ValDiMagra Aug 14 '19 at 17:00

0 Answers0