on a SOAP web service, when I set this filter (to check a API key) :
protected function preFilter($filterChain)
{
if ('testApiKey'
!== Yii::app()->request->getParam('apiKey')) // the 'getParam()' here messes it all
return false;
return true;
}
Here is my test script :
<?php
$client=new SoapClient('https://myapp.local/mycontroller/service?apiKey=testApiKey', array(
'soap_version' => SOAP_1_2, // or try SOAP_1_1
'cache_wsdl' => WSDL_CACHE_NONE, // WSDL_CACHE_BOTH in production
'trace' => 1,
));
var_dump($client->__getFunctions());
var_dump($client->foo('bar'));
What you are doing is you add a GET attribute to the WSDL url, not the method call. So it’s not there when you test for it in preFilter.
You need to add this attribute to every method you want to call through SOAP or use headers in SOAP client. Headers aren’t supported in the WSDL generator shipped with Yii, I’ve built my own and it currently awaits as a pull request.
I don’t know what’s calling that, maybe inspecting the HTTP headers would help.
If you want to do some filtering only for SOAP method calls use the beforeWebMethod and afterWebMethod methods. They are used when you controller implements the IWebServiceProvider interface.