Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP $client->__soapCall('method', $params); VS. $client->method($params);

Tags:

php

soap

I am creating a SOAP client in PHP. Most of my calls look like this

$client->__soapCall('method', $params)

From what I can tell this is one of two ways to call the methods within the WSDL, the other being:

$client->method($params);

I have only been able to get the second way to work when calling a method that only requires strings. Using a method that requires an integer gives me this error:

The value '' cannot be parsed as the type 'Int32'.'

How are these two requests working differently?

like image 894
quaspas Avatar asked Nov 02 '22 15:11

quaspas


1 Answers

Direct call ($client->method()) uses deprecated magical class method __call(). If you are implementing your SoapClient by extending your client class (see example below), you can implement __call() to "callthru" to __soapCall().

class mySoapClient extends SoapClient {
    public function __call($method, $parameters) {
        return $this->__soapCall($method, $parameters);
    }
}

If you are not implementing your client by extending, using direct call ($client->method()) is a bad idea since it will eventually be dropped out of PHP.

like image 141
Niko Hujanen Avatar answered Nov 15 '22 00:11

Niko Hujanen