SOAP_Client - How to handle connection errors?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

SOAP_Client - How to handle connection errors?

Mark Steudel
I'm trying to setup some error handling when connecting to a web service. This is what I tried to do:

$wsdl = 'BadWsdlAddress';

try {
     $client = Zend_Soap_Client( $wsdl );
}
Catch( Exception $e ) {
     echo 'Web service is unavilable, please try again later';
}

There are the errors I get:
Warning: SoapClient::SoapClient(http:/domain.com/dealerlocator.asmx2?WSDL) [soapclient.soapclient]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /path/Zend/library/Zend/Soap/Client/Common.php on line 51

Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://domain.com/dealerlocator.asmx2?WSDL" in /path/Zend/library/Zend/Soap/Client/Common.php on line 51

Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://domain.com/dealerlocator.asmx2?WSDL' in /Users/msteudel/Documents/wwwroot/VTNA/Zend/library/Zend/Soap/Client/Common.php on line 51


Any suggestions?

--

-----------------------------------------
Mark Steudel
P: 206.375.7244
[hidden email]

. : Work : .
http://www.mindfulinteractive.com

. : Play : .
http://www.steudel.org/blog


Reply | Threaded
Open this post in threaded view
|

XDebug?

dmitrybelyakov
Hello,

If i understand you correctly you are getting an uncatchable Fatal Error with such code:

        $wsdl = 'BadWsdlAddress';
        $client = new Zend_Soap_Client($wsdl);

        try
        {
             $client->test();
        }
        catch(Exception $fault)
        {
             echo 'Web service is unavilable, please try again later';
        }


If you are using XDebug - try to disable it. It seems to be an issue with XDebug rather then ZendFramework or PHP itself. The issue is known by XDebug and i think will be fixed in future releases.
If you disable XDebug you can then catch errors with catch(Exception) or catch(SoapFault).

Hope that helps,
Good luck.

Dmitry.
mem
Reply | Threaded
Open this post in threaded view
|

Re: XDebug?

mem

If you are using XDebug - try to disable it. It seems to be an issue with
XDebug rather then ZendFramework or PHP itself. The issue is known by XDebug
and i think will be fixed in future releases.
If you disable XDebug you can then catch errors with catch(Exception) or
catch(SoapFault).

Dmitry.



I would like to suggest that, if this is the issue, please share the Xdebug version and Zend Version you are using.


Thanks in advance,
Márcio


Reply | Threaded
Open this post in threaded view
|

Re: XDebug?

dmitrybelyakov
MEM wrote
I would like to suggest that, if this is the issue, please share the Xdebug
version and Zend Version you are using.

Thanks in advance,
Márcio
Ok, for this I was using

ZendFramework 1.10.2
Xdebug debug v2.1.0beta3 (latest)
PHP 5.3.1
on ZendServer CE 5.0

The issue was described on PHP Issue tracker here
And XDebug issue tracker here

Reply | Threaded
Open this post in threaded view
|

Re: XDebug?

till
In reply to this post by dmitrybelyakov
On Fri, Mar 26, 2010 at 1:25 PM, dmitrybelyakov <[hidden email]> wrote:

>
> Hello,
>
> If i understand you correctly you are getting an uncatchable Fatal Error
> with such code:
>
>        $wsdl = 'BadWsdlAddress';
>        $client = new Zend_Soap_Client($wsdl);
>
>        try
>        {
>             $client->test();
>        }
>        catch(Exception $fault)
>        {
>             echo 'Web service is unavilable, please try again later';
>        }
>
>
> If you are using XDebug - try to disable it. It seems to be an issue with
> XDebug rather then ZendFramework or PHP itself. The issue is known by XDebug
> and i think will be fixed in future releases.
> If you disable XDebug you can then catch errors with catch(Exception) or
> catch(SoapFault).

Can you explain how the "uncatchable" fatal error looks like? I seem
to be missing the relevant email.

Till
Reply | Threaded
Open this post in threaded view
|

Re: XDebug?

dmitrybelyakov
till wrote
On Fri, Mar 26, 2010 at 1:25 PM, dmitrybelyakov <shiftplatform@gmail.com> wrote:

Can you explain how the "uncatchable" fatal error looks like? I seem
to be missing the relevant email.

Till
Sure - it looks like this:

Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'BadWsdlAddress' : failed to load external entity "BadWsdlAddress"

Dmitry.
Reply | Threaded
Open this post in threaded view
|

Re: XDebug?

till
On Fri, Mar 26, 2010 at 2:08 PM, dmitrybelyakov <[hidden email]> wrote:

>
>
> till wrote:
>>
>> On Fri, Mar 26, 2010 at 1:25 PM, dmitrybelyakov <[hidden email]>
>> wrote:
>>
>> Can you explain how the "uncatchable" fatal error looks like? I seem
>> to be missing the relevant email.
>>
>> Till
>>
>>
>
> Sure - it looks like this:
>
> Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'BadWsdlAddress' :
> failed to load external entity "BadWsdlAddress"
>
> Dmitry.

Your try/catch is not enough then.

try {
  $wsdl = 'badaddress';
  $client = new Zend_Soap_Client($wsdl);
  $client->test();
} catch (Exception $e) {
  var_dump($e); // your SoapFault
  exit;
}

Till
Reply | Threaded
Open this post in threaded view
|

Re: XDebug?

dmitrybelyakov
till wrote
Your try/catch is not enough then.

try {
  $wsdl = 'badaddress';
  $client = new Zend_Soap_Client($wsdl);
  $client->test();
} catch (Exception $e) {
  var_dump($e); // your SoapFault
  exit;
}

Till
Indeed. That's because XDebug is producing the fatal error. It will work if you disable XDebug.
Reply | Threaded
Open this post in threaded view
|

Re: SOAP_Client - How to handle connection errors?

Mark Steudel
In reply to this post by Mark Steudel
Mark Steudel <msteudel@...> writes:

>
> I'm trying to setup some error handling when connecting to a web service. This
is what I tried to do:$wsdl = 'BadWsdlAddress';try {     $client =
Zend_Soap_Client( $wsdl );}Catch( Exception $e ) {
>
>      echo 'Web service is unavilable, please try again later';}There are the
errors I get:Warning:
SoapClient::SoapClient(http:/domain.com/dealerlocator.asmx2?WSDL)
[soapclient.soapclient]: failed to open stream: HTTP request failed! HTTP/1.1
404 Not Found
>  in /path/Zend/library/Zend/Soap/Client/Common.php on line 51Warning:
SoapClient::SoapClient() [soapclient.soapclient]:
> I/O warning : failed to load external entity
> "http://domain.com/dealerlocator.asmx2?WSDL" in
> /path/Zend/library/Zend/Soap/Client/Common.php
> on line 51 Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load
> from 'http://domain.com/dealerlocator.asmx2?WSDL' in
> /Users/msteudel/Documents/wwwroot/VTNA/Zend/library/Zend/Soap/Client/Common.php
> on line 51Any suggestions?-- -----------------------------------------Mark
SteudelP: [hidden email]. : Work :
.http://www.mindfulinteractive.com. : Play : .http://www.steudel.org/blog


No thoughts on how to handle this?

MS

Reply | Threaded
Open this post in threaded view
|

Re: SOAP_Client - How to handle connection errors?

dmitrybelyakov
Not sure if i understand correctly - your previous message mas messed.
Still if you wonder how to handle this - there was a hack on XDebug issue tracker that was added to their CVS. I think you may need to update your XDebug from repository.

Alternatively you could set error handler to catch fatal errors - see here.


Dmitry.