Skip to content

Instantly share code, notes, and snippets.

@alfaproject
Created November 12, 2014 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfaproject/051f3fc7989c61ac7373 to your computer and use it in GitHub Desktop.
Save alfaproject/051f3fc7989c61ac7373 to your computer and use it in GitHub Desktop.
SoapServer sub class for debugging requests and responses
<?php
class DebugSoapServer extends SoapServer
{
public function handle($request = null)
{
// check input param
if ($request === null) {
$request = file_get_contents('php://input');
}
// store the request string
$requestSignature = md5($request);
file_put_contents('/tmp/soap_' . $requestSignature . '_request', $request);
// start output buffering
ob_start();
// finaly call SoapServer::handle() - store result
$result = parent::handle($request);
// store the response string
file_put_contents('/tmp/soap_' . $requestSignature . '_response', ob_get_contents());
// flush buffer
ob_flush();
// return stored soap-call result
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment