SoapServer : HTTP_RAW_POST_DATA SOAP Errors resolved

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.

This entry was posted in Ideas. Bookmark the permalink.

4 Responses to SoapServer : HTTP_RAW_POST_DATA SOAP Errors resolved

  1. Gizzle Ent. says:

    I have the same problem, some strange reason nothing i seem to do works. can anyone help use my email.

  2. The fix with:

    $data = file_get_contents(‘php://input’);

    $server->handle($data);

    worked for me. But I still do not understand why I have to do that manually.
    I am running xampp 1.6.2 and enabled all HTTP_RAW_POST_DATA settings in all php.ini files.

    mirko

  3. Ron says:

    Try adding:

    always_populate_raw_post_data=On

    to your php.ini file.

  4. Sujoy says:

    I am still not able to find any solution ??

    ini_set(“soap.wsdl_cache_enabled”, “0″);
    ini_set(“always_populate_raw_post_data”, “On”);

    $data = $HTTP_RAW_POST_DATA;
    $data = file_get_contents(‘php://input’);
    $serverMap = new SOAPServer(null,array(‘uri’=>’urn:someMethod’));
    $serverMap->setClass(‘MmService’);

    $serverMap->setPersistence(SOAP_PERSISTENCE_SESSION);
    $serverMap->handle($data);

    Any Help !!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>