Does anyone know how to log all request and responses with the builtin SoapClient in PHP? I could in fact manually log everything with SoapClient::__getLastRequest()>
Would something like this work?
class MySoapClient extends SoapClient
{
function __soapCall($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null)
{
$out = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
// log request here...
// log response here...
return $out;
}
}
Since SoapClient already sends all requests through __soapCall, you can intercept them by subclassing SoapClient and overriding it. Of course, to make it work you need to also replace every new SoapClient(...) in your code with new MySoapClient(...), but that seems like a pretty easy search and replace task.