PHP 8.4.1 Released!

SoapClient::__call

(PHP 5, PHP 7, PHP 8)

SoapClient::__callLlama a una función de SOAP (obsoleto)

Descripción

public SoapClient::__call(string $function_name, array $arguments): mixed

Llamar a este método directamente está obsoleto. Normalmente, las funciones de SOAP pueden ser invocadas como métodos del objeto SoapClient; en situaciones donde esto no es posible o son necesarias opciones adicionales, use SoapClient::__soapCall().

add a note

User Contributed Notes 2 notes

up
22
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().
up
7
KRavEN
15 years ago
extend of __call thats adds a retry to handle the occasional 'Could not connect to host' exceptions

<?php
class LocalSoapClient extends SoapClient
{

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

while(!
$result && $retry_count < $max_retries)
{
try
{
$result = parent::__call($function_name, $arguments);
}
catch(
SoapFault $fault)
{
if(
$fault->faultstring != 'Could not connect to host')
{
throw
$fault;
}
}
sleep(1);
$retry_count ++;
}
if(
$retry_count == $max_retries)
{
throw new
SoapFault('Could not connect to host after 5 attempts');
}
return
$result;
}
}
?>
To Top