Alternatively, see the "exceptions" option to false in the SoapClient constructor and it will return SoapFault objects instead of throwing errors.
On Sep 16, 4:21 pm, "Aaron Cooper" <[email protected]> wrote: > Don't you hate it when you focus on the highest level so much that you > completely miss the easiest solution? > > I was expecting a SoapClient method, but this does the job exactly as > desired. > > Thanks Stig. > > A > > > > ----- Original Message ----- > From: "Stig Manning" <[email protected]> > To: <[email protected]> > Sent: Thursday, September 16, 2010 4:01 PM > Subject: Re: [phpug] SoapClient Error Handling > > > Try catch? > > > try > > { > > $response = $client->MySoapFunction($params); > > } > > catch (Exception $e) {} > > > -Stig > > > Aaron Cooper wrote, On 16/09/2010 1:19 PM: > >> After a firewall upgrade, I've just inadvertanly introduced an error to > >> an old site that use SoapClient to make a webservice call over a > >> non-standard port. > >> Not a problem to fix, but it highlights some a usability issue for the > >> site, since the failure to connect kills the page at the point it is > >> requested, and html output halts. > >> I can't seem to find much in the way of handling solid connection errors > >> when making a call. Is anyone aware of how? Basically I would like the > >> below function should return a flag to allow the output of some "not > >> available" text on the frontend. > >> public function runService($var1, $var2, $var3) { > >> $wsdl = "http://domain.co.nz:8033/application.asmx?WSDL"; > > >> $client = new SoapClient($wsdl); > >> $params = array( > >> 'Param1' => $var1 > >> 'Param2' => $var2, > >> 'Param3 => $var3 > >> ); > >> $response = $client->MySoapFunction($params); // Fatal error at this > >> line since port is blocked by firewall. All further output is halted. > >> Connection/Error check belongs here > >> return($response->MySoapFunctionResult); > >> } > >> Cheers > >> Aaron > >> -- > >> NZ PHP Users Group:http://groups.google.com/group/nzphpug > >> To post, send email to [email protected] > >> To unsubscribe, send email to > >> [email protected] > > > -- > > NZ PHP Users Group:http://groups.google.com/group/nzphpug > > To post, send email to [email protected] > > To unsubscribe, send email to > > [email protected] -- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
