Workaround for SOAP-ERROR: Parsing WSDL: Couldn't load...?

311 views
Skip to first unread message

Matt.com

unread,
Mar 26, 2012, 9:48:34 AM3/26/12
to Professional PHP Developers
I've been having this issue for awhile now, and I've decided it needs
to be addressed.

I'm writing a web service client using SOAP on a linux server running
PHP 5.3.6.

This web service is called from a cron job that runs continuously.
From time to time the server that hosts the WDSL will go down, at
which point the script aborts due to the "fatal" error of not being
able to load the WSDL.

I've searched the PHP forums for workarounds (yes, I have my
SoapClient instantiation inside of a try-catch block; yes, I've tried
suppressing the error using the @ symbol), to no avail. They just say
that this isn't a bug - PHP just doesn't catch fatal errors (why it's
a fatal error in the first place is beyond me).

If anyone out there has a workaround for this problem, please reply
ASAP.

Here's a snippet of my relevant code:

try {
$ctx = stream_context_create(array('http' =>
array('protocol_version' => 1.0,)));
$client = null;

$client = new SoapClient([myURL], array(
"trace" => 1,
"exceptions" => 0,
"login" => [login],
"password" =>[password],
"authentication" => SOAP_AUTHENTICATION_BASIC,
"stream_context" => $ctx
));

return $client;
} catch (SoapFault $sf) {
return $this->error_out("CF001");
} catch (Exception $e) {
return $this->error_out('CF001');
}

Robert Gonzalez

unread,
Mar 26, 2012, 10:14:59 AM3/26/12
to professi...@googlegroups.com
Have you tried setting a timeout? Or maybe making a simple remote request for the wsdl before making the soap request?
> --
> This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
>
> For information or project assistance please visit :
> http://www.360psg.com
>
> You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
> To post to this group, send email to Professi...@googlegroups.com
> To unsubscribe from this group, send email to Professional-P...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/Professional-PHP

--

Robert Gonzalez
   

Hesham Yosry

unread,
Mar 26, 2012, 1:14:37 PM3/26/12
to professi...@googlegroups.com
Dear Friend,
while i was on one of my projects i have to catch the fatal errors i
was using something like this and convert it to an exception

<?php
function shutdown()
{
$a=error_get_last();
if($a==null)
echo "No errors";
else
print_r($a);

}
register_shutdown_function('shutdown');
ini_set('max_execution_time',1 );
sleep(3);
?>

and it was working.
BTW this is form php.net
http://www.php.net/manual/en/function.set-error-handler.php#106061
i hope this help you.

Best Regards,
Hesham Yosry

Reply all
Reply to author
Forward
Message has been deleted
0 new messages