Search code examples
phpweb-serviceswsdlsoapserver

PHP - SOAP-ENV:ClientBad Request after SoapServer->Handle() - Help


I got a PHP web service that had been running great for a long time, but somewhere a long the way it some how stopped working, and I just can't get it to work again.

I got some php page in which all I do is define a class with functions, and in the end of it I create the SoapServer.

It looks like this -

class MyClassWS
{
     function .....
     function ....
}
ini_set("soap.wsdl_cache_enabled", "0");
    error_log("Server after ini_set");
    $soapserver = new SoapServer("MyWSDL.wsdl");

    error_log("Server after new SoapServer");
$soapserver->setClass("MyClassWS");
    error_log("Server after setClass");
    //error_log(print_r($soapserver->getFunctions()));

    try
    {
        $soapserver->handle();
    }
    catch(Exception $ex)
    {
        error_log("Exception!".$ex->getMessage());

    }
error_log("Finished Handling",0);

Right after the $soapserver->handle(); the code terminates, and I get a vague "SOAP-ENV:ClientBad Request" result on my web page.

This happens when I "require_once" this page, from my index page, so I could call functions that are defined in this class, from my index page.

My guess is that maybe I've been fiddling too much with my WSDL and somehow it screwed up my while WebService, but I tried looking on what's wrong with it, but couldn't get onto anything. Especially because of this annoying vague error message, that doesn't really help.

Thanks!


Solution

  • I think I nicely fixed it by separating the WebService class that included the SoapServer into 2 different classes.

    One that included only the class with the functions, and another that included the WebServer and only had a reference to the class.

    This way I can import the class with the functions without also importing the SoapServer and triggering the handle() function.