1

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!

Dror
  • 2,548
  • 4
  • 33
  • 51
  • Did you try to run the script independently? Does it work then? – Muhammad Zeeshan May 27 '11 at 17:45
  • Yes, if I navigate to that page directly, according to the logs, it passes through the line that originally fails. – Dror May 28 '11 at 09:45
  • I think the problem is because of the Post data that is sent to the page the require_once the WebService page. It seems that for some reason, the SoapServer->Handle() takes into account some data that is sent through POST, and that is what messes it up. Can this be possible? – Dror May 30 '11 at 16:15
  • UPDATE: This was exactly the problem and I got some workaround working around the problem. Though I don't think its too nice. What I'm doing is checking if the content of the post contains some data that I knows that comes with the original page, and if it is, then don't Handle the request. Is there any nicer way? Thanks! – Dror May 30 '11 at 17:02

1 Answers1

1

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.

Dror
  • 2,548
  • 4
  • 33
  • 51