I was having trouble instansiating a soap service using PHP5’s SoapServer class. I kept getting the following fault:

SOAP-ENV:Server Bad Request. Can't find HTTP_RAW_POST_DATA

After a bit of browsing around I found a solution at SitePoint For some reason my installation (From Entropy PHP) of PHP5’s SoapServer does not automatically pick up the global variable HTTP_RAW_POST_DATA. I found some code first tries to get the value of HTTP_RAW_POST_DATA and then as a backup gets content from the stream “php://input” which automatically gets all the contents of POST. We then pass the data we get from the stream and pass it to the SoapServer object through the SoapServer->handle() method.

ini_set("soap.wsdl_cache_enabled", "0");
$data = $HTTP_RAW_POST_DATA;
$data = file_get_contents('php://input');
$server = new SoapServer("service.wsdl"));
$server->setClass("ServiceClass");
$server->setPersistence(SOAP_PERSISTENCE_SESSION);
$server->handle($data);

Now I need to figure out why HTTP_RAW_POST_DATA is not being set.