laravel-soap
laravel-soap copied to clipboard
READ FIRST: Bug in usage of underlying SoapClient library!
There is a documented difference between calling SoapClient::__call()
and SoapClient::__soapCall()
!
You can execute a remote SOAP function like $client->getApples(['number' => 10]);
which results in the SOAP service being called according to the WSDL description.
But when using $client->__soapCall('getApples', ['number' => 10], ...);
the WSDL is not being used. Therefor parameters have to be encapsulated into an additional array like this:
$client->__soapCall('getApples', ['parameters' => ['number' => 10]], ...);
(often it's called parameters
)
This behaviour is also documented on php.net which states that __soapCall
is of lower level functionality than __call
(calling the method "overloaded" as if it was part of the class).
Reference comments on php.net: http://php.net/manual/en/soapclient.soapcall.php#89308 http://php.net/manual/en/soapclient.call.php#114787
This library uses the SoapClient
class via __soapCall
(see here). Therefor this behaviour should be documented in the README or even fixed by adding the encapsulating array automatically (needs debug).
Keep in mind: SoapClient::__call
is acutally deprecated but everybody is used to it.
I just banged my head hard to make the example work.
After doing as you told, I finally made it work.
// Without classmap
$response = $this->soapWrapper->call('Currency.GetConversionAmount', [
'parameters' => [ // TODO this differs from the documentation
'CurrencyFrom' => 'USD',
'CurrencyTo' => 'EUR',
'RateDate' => '2018-04-11T00:00:00',
'Amount' => '1000',
]
]);
@tonila Thank you very much! It saves tons of my effort to make it work!
@jankal Thank you so much for pointing out, that I need to place my parameters in an array item with ['parameters' => I was getting nuts trying to understand, why my parameters did not get passed into the XML request!
@tonila thanks for that, super helpful
For me, just wrapping in another array was enough, without the 'parameters' key. Please add comment to documentation for the non-classmap version as I banged my head for an hour on this.