1

I am trying to test Soap client. I want to see that if the service is down the SoapFault exception is thrown. So here is what I did:

$this->_server = 'http://XXXXXXXX.XXXXXXXX.nl/XXXX.ws/prsdfsfdows.asmx?WSDL';
try {
        $client = new SoapClient($this->_server, array('trace' => 1, 'exception' => 1));
    } catch (SoapFault $e) {
        var_dump($e);
        exit;
    }

I purposely misspelled the server url to be sure that the soap service is down.

I would expect to get a SoapFaultException. In stead I get an E_ERROR

(dev) E_ERROR: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://XXXXX.XXXXXXXX.nl/XXXX.ws/prsdfsfdows.asmx?WSDL' : Premature end of data in tag html line 1 in /var/www/site/web/library/my/webservice.php:60

0 triggerError() called at [/var/www/site/web/library/ErrorHandler.php:212] 1 triggerFatalError() called at [unknown:unknown]

I'm running on PHP 5.4.39

Any suggestions?

EDIT

Some more information:

I was notified about this php bug it turns out that it could be that it has to do with xdebug. So now I have altered my code to :

    try {
        if(function_exists('xdebug_disable')) {
            xdebug_disable();
        }

        $client = @new SoapClient($this->_server, array("exceptions"=> 1));
        $this->setClient($client);
        xdebug_enable();
    } catch (SoapFault $ex) {
        echo 'soapfault';
        echo $ex->getTraceAsString();
        exit;
    } catch (Exception $e) {
        echo $e->getMessage();
    }

But I still see the E_ERROR in stead of the SoapFault

sanders
  • 10,794
  • 27
  • 85
  • 127

0 Answers0