SoapClient: Catchable Fatal Error for invalid WSDL
| From: | Nicolai Scheer | Date: | Tue, 09 Oct 2012 11:34:26 +0000 |
| Subject: | SoapClient: Catchable Fatal Error for invalid WSDL | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-63300@lists.php.net to get a copy of this message | ||
Hi!
Just read the comments for Bug #47584: WSDL error in soapClient causes
Fatal Error.
If a SoapClient is created and the WSDL can not be found, an Exception
is thrown:
<?php
try
{
$x = new SoapClient( "non-existent.wsdl", array( "exceptions" => 1 ) );
}
catch ( Exception $e )
{
echo $e->faultstring;
}
echo "ok\n";
$error = error_get_last();
print_r( $error );
?>
Although I'm using exceptions here, an E_ERROR gets "registered", thus
the output is:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'non-existent.wsdl' :
failed to load external entity "non-existent.wsdl"
ok
Array
(
[type] => 1
[message] => SOAP-ERROR: Parsing WSDL: Couldn't load from
'non-existent.wsdl' : failed to load external entity
"non-existent.wsdl"
[file] => Y:\client2.phb
[line] => 5
)
Can anybody comment on this behaviour? Should an error be registered
when exceptions are used? Should this be an E_RECOVERABLE_ERROR
instead?
The specific problem is that we use a shutdown function that utilizes
error_get_last() to see if a fatal error orccured and then tries to
redirect to a specific error page.
Now we call a php script via ajax that tries to connect to a soap
service. If the service is unreachable we correctly catch the
exception, but the registered E_ERROR gets processed on shutdown, thus
redirecting...
Thanks and greetings
Nico