Additional information to the comment of "Joeri Thissen" (http://www.php.net/manual/en/soapserver.handle.php#113866)
In some cases the replacements generates a timeout (looks like it is in combination with Nginx). The problem is that PHP has already sent a content-length, and the webserver is still waiting for new content.
To fix this you have to reset the HTTP Content-Length with the right value:
<?php
ob_start();
$soapServer->handle();
$result = ob_get_contents();
ob_end_clean();
$result = str_replace("abcdef", "abc", $result);
$length = strlen($result);
header("Content-Length: ".$length);
echo $result;