Skip to content
Advertisement

PHP SOAP operations that start with an underscore

With PHPs SOAP implementation, I can’t call methods from the WDSL, if they start with an underscore. I.e.:

$result = $server->_-testing_-getPrices(array('Receiver'=>'John'));

DOESN’T WORK!

However,

$result = $server->getPrices(array('Receiver'=>'John'));

WORKS AS EXPECTED, however, the SOAP server i’m requesting to doesn’t have this operation. The error that PHP spits out with the FIRST ONE is:

Notice: Undefined property: SoapClient::$_ in D:SERVERwwwtest123.php on line 4

Notice: Use of undefined constant testing_ - assumed 'testing_' in D:SERVERwwwtest123.php on line 4

Fatal error: Call to undefined function getPrices() in D:SERVERwwwtest123.php on line 4

This is IMHO a bug, or does anyone know how to go around this?

Advertisement

Answer

PHP’s functions cannot contain - in their names: http://www.php.net/manual/en/functions.user-defined.php . So, you have to use this to call your method: http://www.php.net/manual/en/soapclient.soapcall.php

$result = $server->__soapCall('_-testing_-getPrices',array('Receiver'=>'John'));
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement