(PHP 5, PHP 7, PHP 8)

SoapClient::__callВызывает SOAP-функцию (устаревший метод)


public SoapClient::__call(string $name, array $args): mixed

Вызов этого метода напрямую устарел. Обычно функции SOAP могут вызываться как методы объекта SoapClient; в ситуациях, когда это невозможно или требуются дополнительные опции, используйте метод SoapClient::__soapCall()..

Список параметров


Имя вызываемой функции SOAP.


Массив аргументов для передачи функции. Может быть упорядоченный или ассоциативный массив. Обратите внимание, что большинство серверов SOAP требуют предоставления имён параметров, в этом случае должен быть ассоциативный массив.

Возвращаемые значения

Функции SOAP могут возвращать одно или несколько значений. Если функция SOAP возвращает только одно значение, то возвращаемое значение будет скаляром. Если возвращается несколько значений, то вместо них возвращается ассоциативный массив именованных выходных параметров.

В случае возникновения ошибки, если объект SoapClient был объявлен с опцией exceptions со значением false, будет возвращён объект SoapFault.

add a note

User Contributed Notes 4 notes

philipp dot gruber at catchoftheday dot com dot au
10 years ago
If you are using a WSDL, the library will strip out anything from your parameters that is not defined in WSDL, without giving you any notice about this.

So if your parameters are not fully matching the WSDL, it will simply send no parameters at all.
This can be a bit hard to debug if you don't have access to the target server.

__soapCall() expects parameters in an array called 'parameters' as opposed to calling the function via it's WSDL name, where it accepts the parameters as a plain array.

I.e. if a function called sendOrder expects a parameter (array) called orderDetails, you can call it like this:

$orderDetails = array(/* your data */);
$soap->sendOrder(array('orderDetails' => $orderDetails));

Which is equivalent to:

$client->__soapCall('sendOrder', array('parameters' => array('orderDetails' => $orderDetails)));

Note the additional 'parameters' key used in __soapCall().
14 years ago
extend of __call thats adds a retry to handle the occasional 'Could not connect to host' exceptions

class LocalSoapClient extends SoapClient

public function
__call($function_name, $arguments)
$result = false;
$max_retries = 5;
$retry_count = 0;

$result && $retry_count < $max_retries)
$result = parent::__call($function_name, $arguments);
SoapFault $fault)
$fault->faultstring != 'Could not connect to host')
$retry_count ++;
$retry_count == $max_retries)
throw new
SoapFault('Could not connect to host after 5 attempts');
bananos at dev dot co dot ua
16 years ago
I'm writing PHP SOAP client (based on php_soap extension) which uses Google AdService,
today, I tried to create sample Ad using AdService::addAds() and discovered that my SOAP library does not pass
"headline", "description1", "description2" parameters in SOAP request.

First, I thought that this was something wrong with my data, coz I was getting validation errors like
"One or more input elements failed validation." Then I decided to take a look at WSDL description

And voilà ! I've found this:

<complexType name="Ad" abstract="true">
<element name="adGroupId" type="xsd:int"/>
<element name="adType" nillable="true" minOccurs="0" type="impl:AdType"/>
<element name="destinationUrl" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="disapproved" type="xsd:boolean"/>
<element name="displayUrl" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="exemptionRequest" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="id" type="xsd:long"/>
<element name="status" nillable="true" minOccurs="0" type="impl:AdStatus"/>


There is no any ''description", "headline1", "headline2", however there is another complexType

<complexType name="TextAd">
<extension base="impl:Ad">

<element name="description1" nillable="true" type="xsd:string"/>
<element name="description2" nillable="true" type="xsd:string"/>
<element name="headline" nillable="true" type="xsd:string"/>


So, the thing is when you are working with php_soap be aware of complexType extensions which does not work in php_soap when you try to do things like:


= new
'trace' => true,
'exceptions' => true,


$entropy = substr(md5(rand(0, time())), 0, 10);
//create Ad test structure
$sample_ad = array(
"id" => 0,
"adGroupId" => 0,
"adType" => 'TextAd',
"disapproved" => false,
"destinationUrl" => '',
"displayUrl" => '',
"status" => "Paused", // Enabled / Disabled
"descr_iption1" => 'D1_'.$entropy,
"des_cription2" => 'D2_'.$entropy,
"head_line" => 'H_'.$entropy

$client->addAds(array('ads' => array($sample_ad) );
Samil Abud
16 years ago
This is a good example, for the SOAP function "__call".
However it is deprecated.

= "";
$int_zona = 5;
$int_peso = 1001;
$cliente = new SoapClient($wsdl);
"<p>Envio Internacional: ";
$vem = $cliente->__call('CustoEMSInternacional',array($int_zona, $int_peso));
To Top