I'm working on an update to my PHP Web Services book and with PHP 7 likely to release before the book even makes it into print, I'm testing all my example code across PHP 5.6 and PHP 7 ... which today gave me a weird problem with a very, very simple SOAP example.
<?php $client = new SoapClient('http://api.radioreference.com/soap2/?wsdl&v=latest'); $countries = $client->getCountryList(); print_r($countries);
This example works fine with PHP 5 but when I ran it with PHP 7 (after realising I needed to recompile with
--enable-soap), I got this error:
Fatal error: Uncaught SoapFault exception: [Client] Function ("getCountryList") is not a valid method for this service ...
Hmm. So I complained about it on IRC and someone else tried it on 7 and said it worked fine (thanks @akrabat) but that it didn't work under 5.6 for him.
I can only speculate about what changed between versions and it's probably a good thing, whatever it is, but it seems like once the WSDL is cached locally from one version of PHP, it makes no sense with the other version. To fix it, disable the WSDL cache:
This worked for me, and I am not sure how I would have found a strange SOAP fault between PHP versions other than by a lucky help from someone else, so it's here in the hope that it saves time for someone else too!